#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include using namespace std; using namespace chrono; const int MAX=2048; static uint32_t randXor(){ static uint32_t x=123456789; static uint32_t y=362436069; static uint32_t z=521288629; static uint32_t w=88675123; uint32_t t; t=x^(x<<11); x=y;y=z;z=w; return w=(w^(w>>19))^(t^(t>>8)); } static double rand01(){ return (randXor()+0.5)*(1.0/UINT_MAX); } int calc(vector&A,vector&B,vector&C,vector&P,vector&Q,vector&R,vector&S){ int num=0; rep(i,MAX){ bool b=false; if(S[A[i]]==P[i]) b=true; if(S[B[i]]==Q[i]) b=true; if(S[C[i]]==R[i]) b=true; if(b) num++; else break; } return num; } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); vector A(MAX),B(MAX),C(MAX),P(MAX),Q(MAX),R(MAX); vector A0,A1,B0,B1,C0,C1; rep(i,MAX){ cin>>A[i]>>B[i]>>C[i]>>P[i]>>Q[i]>>R[i]; if(P[i]==0) A0.push_back(i); else A1.push_back(i); if(Q[i]==0) B0.push_back(i); else B1.push_back(i); if(R[i]==0) C0.push_back(i); else C1.push_back(i); } A0.push_back(MAX),A1.push_back(MAX),B0.push_back(MAX); B1.push_back(MAX),C0.push_back(MAX),C1.push_back(MAX); auto startClock=system_clock::now(); int bestscore=0; vector S(256),bestS(256); const static double START_TEMP=1500; const static double END_TEMP = 100; const static double END_TIME=1.8; double time=0.0; do{ const double progressRatio=time/END_TIME; const double temp=START_TEMP+(END_TEMP-START_TEMP)*progressRatio; int score=-1; rep(i,2048){ if(S[A[i]]==P[i] || S[B[i]]==Q[i] || S[C[i]]==R[i]) continue; else{ score=i; break; } } if(score>bestscore){ bestscore=score; bestS=S; } ll t=randXor(); if(t%3==0) S[A[score]]^=1; else if(t%3==1) S[B[score]]^=1; else S[C[score]]^=1; time=(duration_cast(system_clock::now()-startClock).count()*1e-6); }while(time=0;i--) cout<