結果
問題 |
No.5005 3-SAT
|
ユーザー |
|
提出日時 | 2022-04-07 02:40:00 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,992 ms / 2,000 ms |
コード長 | 2,058 bytes |
コンパイル時間 | 4,373 ms |
実行使用メモリ | 5,164 KB |
スコア | 9,854 |
最終ジャッジ日時 | 2022-04-29 13:57:24 |
合計ジャッジ時間 | 209,187 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 100 |
ソースコード
#pragma GCC target("avx2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> #include<sys/time.h> #define B_SIZE 256 #define C_SIZE 2048 using namespace std; long long start_time; void start_clock(){ struct timeval tv; gettimeofday(&tv, NULL); start_time=(tv.tv_sec*1000000+tv.tv_usec); } long long current_clock(){ struct timeval tv; gettimeofday(&tv, NULL); long long current_time=(tv.tv_sec*1000000+tv.tv_usec); return (current_time-start_time); //cout << current_time-start_time << "(us)\n"; } uint32_t xor64(void){ static uint64_t x = 88172645463325252ULL; x = x ^ (x << 13); x = x ^ (x >> 7); return x = x ^ (x << 17); } int a[C_SIZE][3]; char p[C_SIZE][3]; int mxm=-1; string res,cs; set<int> unsat; int sat_cnt[C_SIZE]={0}; using pi=pair<int,int>; vector<vector<pi>> g; int main(){ start_clock(); ios::sync_with_stdio(false); cin.tie(nullptr); g.resize(B_SIZE); for(int i=0;i<C_SIZE;i++){ cin >> a[i][0] >> a[i][1] >> a[i][2]; int pp,qq,rr; cin >> pp >> qq >> rr; p[i][0]=(pp+'0'); p[i][1]=(qq+'0'); p[i][2]=(rr+'0'); g[a[i][0]].push_back({i,0}); g[a[i][1]].push_back({i,1}); g[a[i][2]].push_back({i,2}); if(pp==0){sat_cnt[i]++;} if(qq==0){sat_cnt[i]++;} if(rr==0){sat_cnt[i]++;} if(sat_cnt[i]==0){unsat.insert(i);} } for(int i=0;i<B_SIZE;i++){cs.push_back('0');} int i=0; while(1){ int od=(*unsat.begin()); if(mxm<od){ mxm=od; res=cs; } int fp=xor64()%B_SIZE; for(auto &ny : g[fp]){ if(cs[fp]==p[ny.first][ny.second]){ sat_cnt[ny.first]--; if(sat_cnt[ny.first]==0){unsat.insert(ny.first);} } else{ if(sat_cnt[ny.first]==0){unsat.erase(ny.first);} sat_cnt[ny.first]++; } } cs[fp]=('0'+'1'-cs[fp]); //cerr << fp << '\n'; i++; if(i==500){ if(current_clock()>=1990000){break;} i=0; } } //cout << mxm << '\n'; reverse(res.begin(),res.end()); cout << res << '\n'; return 0; }