CodeChef submission 130249 (C++ 4.0.0-8) plaintext list. Status: WA, problem J5, contest NOV09. By naughty (Yash), 2009-11-11 04:05:34.
/* Author :: Yash */ #include <vector> #include <list> #include <cassert> #include <sstream> #include <map> #include <set> #include <climits> #include <deque> #include <fstream> #include <stack> #include <bitset> #include <stack> #include <queue> #include <algorithm> #include <functional> #include <numeric> #include <cstring> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; template<class A, class B> A cvt(B x) {stringstream s;s<<x;A r;s>>r;return r;} #define FOR(i,a,b) for(int i= (int )a ; i < (int )b ; ++i) #define REP(i,n) FOR(i,0,n) #define PB push_back #define PP pop() #define EM empty() #define INF 1000000000 #define PF push_front #define ALL(x) x.begin(),x.end() #define SORT(x) sort(ALL(x)) #define V(x) vector< x > #define Debug false #define PRINT(x) cout << #x << " " << x << endl #define LET(x,a) __typeof(a) x(a) #define IFOR(i,a,b) for(LET(i,a);i!=(b);++i) #define EACH(it,v) IFOR(it,v.begin(),v.end()) #define PRESENT(c,x) ((c).find(x) != (c).end()) #define SZ(x) x.size(); #define CPRESENT(c,x) (find(c.begin(),c.end(),x) != (c).end()) #define D(N) int N #define S(N) scanf("%d",&N) #define Max 510 typedef pair<int,int> PI; typedef pair<int,PI> TRI; typedef V( int ) VI; typedef V( PI ) VII; typedef V( string ) VS; typedef long long LL; /* Okay, So a Brand New one * We'll Run this only for Songs <= 150. */ int Songs, Dancers, Likes[Max][Max]; int Selected[Max], BoringAdded[Max], BoredumFactor[Max], Present[Max], TotalScore; VI Final, FinalAns; PI Try2() { /* This Gives out the best one * The Best Song for the moment */ int Best = -1, TheOne = 0,Profit = 0; REP(i,Songs) { if(!Selected[i]) { Profit = 0; REP(j,Dancers) { if(!Present[j] && BoringAdded[j] < BoredumFactor[j] && Likes[j][i]) Profit++; if(!Likes[j][i] && Present[j] && (BoringAdded[j] + 1) >= BoredumFactor[j]) Profit--; // if(!Present[j] && (BoringAdded[j] + 1) >= BoredumFactor[j] && !Neg[j]) Profit--; } if(Best <= Profit) { Best = Profit; TheOne = i; } } } return PI(Best,TheOne); } PI Try3() { /* This Gives out the best one * The Best Song for the moment */ int Best = -1, TheOne = 0,Profit = 0; REP(i,Songs) { if(!Selected[i]) { Profit = 0; REP(j,Dancers) { if(!Present[j] && BoringAdded[j] < BoredumFactor[j] && Likes[j][i]) Profit++; if(!Likes[j][i] && Present[j] && (BoringAdded[j] + 1) >= BoredumFactor[j]) Profit--; // if(!Present[j] && (BoringAdded[j] + 1) >= BoredumFactor[j] && !Neg[j]) Profit--; } if(Best < Profit) { Best = Profit; TheOne = i; } } } return PI(Best,TheOne); } int First(bool Check) { // Keep Things Clear and Simple. PI top = Check ? Try2() : Try3(); Final.clear();int newBest = 0; while(top.first > 0) { int t = top.second; Selected[t] = 1; REP(i,Dancers) { if(Likes[i][t] && !Present[i]) Present[i] = 1; if(!Likes[i][t]) BoringAdded[i]++; if(BoringAdded[i] >= BoredumFactor[i]) Present[i] = 0; } newBest += top.first; Final.PB(t); top = Check ? Try2() : Try3(); } if(newBest > TotalScore) TotalScore = newBest, FinalAns = Final; } int main() { //if ( Songs >= 150 ) { puts("0"); return 0; } // Not Bothering About them. TotalScore = 0; First(0); First(1); // printf("%d\n",TotalScore); cerr << TotalScore << endl; return 0; }
Comments

