Artifact Content
Not logged in

Artifact 56f115457a162ea843fc4af46a7e057eaf2115ff


#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef complex<LD> CMP;

class TheDevice { public:
	int minimumAdditional(vector <string> plates)
	{
		int NB = plates[0].size();
		int lackMax = 0;
		for(int i=0; i<NB; ++i)
		{
			int zero=0, one=0;
			for(int k=0; k<plates.size(); ++k)
				(plates[k][i]=='0' ? zero : one)++;
			int lack = max(0,1-zero)+max(0,2-one);
			lackMax = max(lackMax, lack);
		}
		return lackMax;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const int& Expected, const int& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, TheDevice().minimumAdditional(plates));}
int main(){

CASE(0)
	string plates_[] = {"010",
 "011",
 "101"};
	  vector <string> plates(plates_, plates_+sizeof(plates_)/sizeof(*plates_)); 
	int _ = 1; 
END
CASE(1)
	string plates_[] = {"0",
 "1",
 "0",
 "1"};
	  vector <string> plates(plates_, plates_+sizeof(plates_)/sizeof(*plates_)); 
	int _ = 0; 
END
CASE(2)
	string plates_[] = {"01010101",
 "10101010"};
	  vector <string> plates(plates_, plates_+sizeof(plates_)/sizeof(*plates_)); 
	int _ = 1; 
END
CASE(3)
	string plates_[] = {"10010101011",
 "00010101001",
 "00100010111",
 "00101010101",
 "01010111101"};
	  vector <string> plates(plates_, plates_+sizeof(plates_)/sizeof(*plates_)); 
	int _ = 1; 
END
CASE(4)
	string plates_[] = {"1101001011010",
 "0010000010101",
 "1010101011110",
 "1101010100111",
 "1011111110111"};
	  vector <string> plates(plates_, plates_+sizeof(plates_)/sizeof(*plates_)); 
	int _ = 0; 
END
/*
CASE(5)
	string plates_[] = ;
	  vector <string> plates(plates_, plates_+sizeof(plates_)/sizeof(*plates_)); 
	int _ = ; 
END
CASE(6)
	string plates_[] = ;
	  vector <string> plates(plates_, plates_+sizeof(plates_)/sizeof(*plates_)); 
	int _ = ; 
END
*/
}
// END CUT HERE