結果
問題 | No.5005 3-SAT |
ユーザー | umezo |
提出日時 | 2022-04-29 14:53:14 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,803 ms / 2,000 ms |
コード長 | 2,798 bytes |
コンパイル時間 | 2,052 ms |
実行使用メモリ | 3,724 KB |
スコア | 17,528 |
最終ジャッジ日時 | 2022-04-29 14:56:26 |
合計ジャッジ時間 | 188,997 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,803 ms
3,592 KB |
testcase_01 | AC | 1,803 ms
3,484 KB |
testcase_02 | AC | 1,801 ms
3,488 KB |
testcase_03 | AC | 1,802 ms
3,620 KB |
testcase_04 | AC | 1,803 ms
3,544 KB |
testcase_05 | AC | 1,802 ms
3,560 KB |
testcase_06 | AC | 1,803 ms
3,532 KB |
testcase_07 | AC | 1,802 ms
3,548 KB |
testcase_08 | AC | 1,802 ms
3,492 KB |
testcase_09 | AC | 1,803 ms
3,488 KB |
testcase_10 | AC | 1,803 ms
3,628 KB |
testcase_11 | AC | 1,802 ms
3,484 KB |
testcase_12 | AC | 1,803 ms
3,640 KB |
testcase_13 | AC | 1,802 ms
3,552 KB |
testcase_14 | AC | 1,802 ms
3,488 KB |
testcase_15 | AC | 1,803 ms
3,632 KB |
testcase_16 | AC | 1,803 ms
3,536 KB |
testcase_17 | AC | 1,803 ms
3,484 KB |
testcase_18 | AC | 1,802 ms
3,636 KB |
testcase_19 | AC | 1,801 ms
3,592 KB |
testcase_20 | AC | 1,803 ms
3,588 KB |
testcase_21 | AC | 1,803 ms
3,536 KB |
testcase_22 | AC | 1,802 ms
3,596 KB |
testcase_23 | AC | 1,803 ms
3,492 KB |
testcase_24 | AC | 1,802 ms
3,584 KB |
testcase_25 | AC | 1,802 ms
3,536 KB |
testcase_26 | AC | 1,802 ms
3,624 KB |
testcase_27 | AC | 1,802 ms
3,540 KB |
testcase_28 | AC | 1,803 ms
3,540 KB |
testcase_29 | AC | 1,803 ms
3,632 KB |
testcase_30 | AC | 1,802 ms
3,552 KB |
testcase_31 | AC | 1,802 ms
3,548 KB |
testcase_32 | AC | 1,803 ms
3,628 KB |
testcase_33 | AC | 1,802 ms
3,580 KB |
testcase_34 | AC | 1,803 ms
3,584 KB |
testcase_35 | AC | 1,803 ms
3,552 KB |
testcase_36 | AC | 1,801 ms
3,488 KB |
testcase_37 | AC | 1,803 ms
3,588 KB |
testcase_38 | AC | 1,803 ms
3,592 KB |
testcase_39 | AC | 1,802 ms
3,596 KB |
testcase_40 | AC | 1,803 ms
3,480 KB |
testcase_41 | AC | 1,803 ms
3,480 KB |
testcase_42 | AC | 1,802 ms
3,592 KB |
testcase_43 | AC | 1,803 ms
3,584 KB |
testcase_44 | AC | 1,802 ms
3,492 KB |
testcase_45 | AC | 1,803 ms
3,548 KB |
testcase_46 | AC | 1,803 ms
3,584 KB |
testcase_47 | AC | 1,802 ms
3,532 KB |
testcase_48 | AC | 1,802 ms
3,584 KB |
testcase_49 | AC | 1,802 ms
3,484 KB |
testcase_50 | AC | 1,802 ms
3,484 KB |
testcase_51 | AC | 1,803 ms
3,496 KB |
testcase_52 | AC | 1,803 ms
3,536 KB |
testcase_53 | AC | 1,802 ms
3,576 KB |
testcase_54 | AC | 1,802 ms
3,496 KB |
testcase_55 | AC | 1,802 ms
3,492 KB |
testcase_56 | AC | 1,803 ms
3,636 KB |
testcase_57 | AC | 1,803 ms
3,636 KB |
testcase_58 | AC | 1,803 ms
3,604 KB |
testcase_59 | AC | 1,802 ms
3,600 KB |
testcase_60 | AC | 1,803 ms
3,592 KB |
testcase_61 | AC | 1,801 ms
3,588 KB |
testcase_62 | AC | 1,803 ms
3,560 KB |
testcase_63 | AC | 1,802 ms
3,548 KB |
testcase_64 | AC | 1,803 ms
3,556 KB |
testcase_65 | AC | 1,802 ms
3,552 KB |
testcase_66 | AC | 1,802 ms
3,588 KB |
testcase_67 | AC | 1,802 ms
3,640 KB |
testcase_68 | AC | 1,803 ms
3,488 KB |
testcase_69 | AC | 1,802 ms
3,588 KB |
testcase_70 | AC | 1,803 ms
3,552 KB |
testcase_71 | AC | 1,802 ms
3,540 KB |
testcase_72 | AC | 1,802 ms
3,556 KB |
testcase_73 | AC | 1,802 ms
3,640 KB |
testcase_74 | AC | 1,803 ms
3,488 KB |
testcase_75 | AC | 1,803 ms
3,632 KB |
testcase_76 | AC | 1,802 ms
3,588 KB |
testcase_77 | AC | 1,802 ms
3,592 KB |
testcase_78 | AC | 1,802 ms
3,552 KB |
testcase_79 | AC | 1,803 ms
3,556 KB |
testcase_80 | AC | 1,801 ms
3,636 KB |
testcase_81 | AC | 1,803 ms
3,640 KB |
testcase_82 | AC | 1,802 ms
3,548 KB |
testcase_83 | AC | 1,802 ms
3,724 KB |
testcase_84 | AC | 1,803 ms
3,640 KB |
testcase_85 | AC | 1,803 ms
3,584 KB |
testcase_86 | AC | 1,802 ms
3,616 KB |
testcase_87 | AC | 1,803 ms
3,584 KB |
testcase_88 | AC | 1,801 ms
3,628 KB |
testcase_89 | AC | 1,803 ms
3,492 KB |
testcase_90 | AC | 1,803 ms
3,588 KB |
testcase_91 | AC | 1,802 ms
3,588 KB |
testcase_92 | AC | 1,801 ms
3,612 KB |
testcase_93 | AC | 1,802 ms
3,552 KB |
testcase_94 | AC | 1,802 ms
3,584 KB |
testcase_95 | AC | 1,802 ms
3,632 KB |
testcase_96 | AC | 1,803 ms
3,552 KB |
testcase_97 | AC | 1,803 ms
3,488 KB |
testcase_98 | AC | 1,802 ms
3,612 KB |
testcase_99 | AC | 1,802 ms
3,676 KB |
ソースコード
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; using namespace chrono; 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<int>&A,vector<int>&B,vector<int>&C,vector<int>&P,vector<int>&Q,vector<int>&R,vector<int>&S){ int num=0; rep(i,2048){ 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<int> S(256),used(256); vector<int> A(2048),B(2048),C(2048),P(2048),Q(2048),R(2048); vector<int> A0,A1,B0,B1,C0,C1; rep(i,2048){ cin>>A[i]>>B[i]>>C[i]>>P[i]>>Q[i]>>R[i]; if(A[i]==0) A0.push_back(i); else A1.push_back(i); if(B[i]==0) B0.push_back(i); else B1.push_back(i); if(C[i]==0) C0.push_back(i); else C1.push_back(i); } A0.push_back(2048),A1.push_back(2048),B0.push_back(2048); B1.push_back(2048),C0.push_back(2048),C1.push_back(2048); auto startClock=system_clock::now(); int score=0; int bestscore=0; vector<int> bestS; const static double END_TIME=1.8; double time=0.0; do{ vector<int> S(256),used(256); int score=0; rep(i,2048){ score++; if(used[A[i]] && S[A[i]]==P[i]) continue; if(used[B[i]] && S[B[i]]==Q[i]) continue; if(used[C[i]] && S[C[i]]==R[i]) continue; int a=-1,b=-1,c=-1; if(used[A[i]]==0 && P[i]==0) a=lower_bound(ALL(A1),i)-A1.begin(); if(used[A[i]]==0 && P[i]==1) a=lower_bound(ALL(A0),i)-A0.begin(); if(used[B[i]]==0 && Q[i]==0) b=lower_bound(ALL(B1),i)-B1.begin(); if(used[B[i]]==0 && Q[i]==1) b=lower_bound(ALL(B0),i)-B0.begin(); if(used[C[i]]==0 && R[i]==0) c=lower_bound(ALL(C1),i)-C1.begin(); if(used[C[i]]==0 && R[i]==1) c=lower_bound(ALL(C0),i)-C0.begin(); if(a==-1 && b==-1 && c==-1){ score--; break; } if(a>=b && a>=c){ S[A[i]]=P[i]; used[A[i]]=1; } else if(b>=c && b>=c){ S[B[i]]=Q[i]; used[B[i]]=1; } else{ S[C[i]]=R[i]; used[C[i]]=1; } } if(score>bestscore){ bestscore=score; bestS=S; } time=(duration_cast<microseconds>(system_clock::now()-startClock).count()*1e-6); }while(time<END_TIME); for(int i=255;i>=0;i--) cout<<bestS[i]; cout<<endl; cout<<calc(A,B,C,P,Q,R,bestS)<<endl; return 0; }