結果
問題 | No.5005 3-SAT |
ユーザー | merom686 |
提出日時 | 2022-04-29 15:54:20 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 738 ms / 2,000 ms |
コード長 | 4,051 bytes |
コンパイル時間 | 2,446 ms |
実行使用メモリ | 3,636 KB |
スコア | 40,462 |
最終ジャッジ日時 | 2022-04-29 15:55:24 |
合計ジャッジ時間 | 62,151 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 517 ms
3,480 KB |
testcase_01 | AC | 504 ms
3,568 KB |
testcase_02 | AC | 552 ms
3,496 KB |
testcase_03 | AC | 505 ms
3,540 KB |
testcase_04 | AC | 497 ms
3,472 KB |
testcase_05 | AC | 482 ms
3,480 KB |
testcase_06 | AC | 514 ms
3,548 KB |
testcase_07 | AC | 677 ms
3,488 KB |
testcase_08 | AC | 561 ms
3,584 KB |
testcase_09 | AC | 519 ms
3,588 KB |
testcase_10 | AC | 499 ms
3,544 KB |
testcase_11 | AC | 492 ms
3,584 KB |
testcase_12 | AC | 482 ms
3,564 KB |
testcase_13 | AC | 737 ms
3,572 KB |
testcase_14 | AC | 738 ms
3,572 KB |
testcase_15 | AC | 521 ms
3,632 KB |
testcase_16 | AC | 491 ms
3,480 KB |
testcase_17 | AC | 482 ms
3,620 KB |
testcase_18 | AC | 506 ms
3,612 KB |
testcase_19 | AC | 553 ms
3,560 KB |
testcase_20 | AC | 498 ms
3,548 KB |
testcase_21 | AC | 495 ms
3,512 KB |
testcase_22 | AC | 519 ms
3,560 KB |
testcase_23 | AC | 511 ms
3,480 KB |
testcase_24 | AC | 548 ms
3,528 KB |
testcase_25 | AC | 639 ms
3,544 KB |
testcase_26 | AC | 640 ms
3,548 KB |
testcase_27 | AC | 510 ms
3,532 KB |
testcase_28 | AC | 544 ms
3,560 KB |
testcase_29 | AC | 645 ms
3,588 KB |
testcase_30 | AC | 598 ms
3,612 KB |
testcase_31 | AC | 499 ms
3,560 KB |
testcase_32 | AC | 475 ms
3,460 KB |
testcase_33 | AC | 497 ms
3,540 KB |
testcase_34 | AC | 678 ms
3,636 KB |
testcase_35 | AC | 506 ms
3,544 KB |
testcase_36 | AC | 609 ms
3,512 KB |
testcase_37 | AC | 550 ms
3,468 KB |
testcase_38 | AC | 533 ms
3,496 KB |
testcase_39 | AC | 639 ms
3,524 KB |
testcase_40 | AC | 534 ms
3,624 KB |
testcase_41 | AC | 467 ms
3,540 KB |
testcase_42 | AC | 526 ms
3,548 KB |
testcase_43 | AC | 543 ms
3,544 KB |
testcase_44 | AC | 530 ms
3,536 KB |
testcase_45 | AC | 498 ms
3,464 KB |
testcase_46 | AC | 519 ms
3,480 KB |
testcase_47 | AC | 536 ms
3,572 KB |
testcase_48 | AC | 525 ms
3,528 KB |
testcase_49 | AC | 562 ms
3,508 KB |
testcase_50 | AC | 483 ms
3,544 KB |
testcase_51 | AC | 520 ms
3,480 KB |
testcase_52 | AC | 530 ms
3,532 KB |
testcase_53 | AC | 515 ms
3,568 KB |
testcase_54 | AC | 529 ms
3,512 KB |
testcase_55 | AC | 499 ms
3,592 KB |
testcase_56 | AC | 499 ms
3,620 KB |
testcase_57 | AC | 545 ms
3,480 KB |
testcase_58 | AC | 501 ms
3,492 KB |
testcase_59 | AC | 466 ms
3,464 KB |
testcase_60 | AC | 519 ms
3,588 KB |
testcase_61 | AC | 473 ms
3,536 KB |
testcase_62 | AC | 511 ms
3,476 KB |
testcase_63 | AC | 520 ms
3,584 KB |
testcase_64 | AC | 496 ms
3,476 KB |
testcase_65 | AC | 493 ms
3,548 KB |
testcase_66 | AC | 506 ms
3,564 KB |
testcase_67 | AC | 496 ms
3,468 KB |
testcase_68 | AC | 492 ms
3,488 KB |
testcase_69 | AC | 507 ms
3,484 KB |
testcase_70 | AC | 486 ms
3,480 KB |
testcase_71 | AC | 501 ms
3,488 KB |
testcase_72 | AC | 514 ms
3,592 KB |
testcase_73 | AC | 493 ms
3,464 KB |
testcase_74 | AC | 565 ms
3,548 KB |
testcase_75 | AC | 518 ms
3,544 KB |
testcase_76 | AC | 483 ms
3,596 KB |
testcase_77 | AC | 483 ms
3,568 KB |
testcase_78 | AC | 494 ms
3,488 KB |
testcase_79 | AC | 501 ms
3,544 KB |
testcase_80 | AC | 500 ms
3,600 KB |
testcase_81 | AC | 556 ms
3,544 KB |
testcase_82 | AC | 467 ms
3,480 KB |
testcase_83 | AC | 526 ms
3,552 KB |
testcase_84 | AC | 496 ms
3,480 KB |
testcase_85 | AC | 492 ms
3,576 KB |
testcase_86 | AC | 500 ms
3,552 KB |
testcase_87 | AC | 519 ms
3,544 KB |
testcase_88 | AC | 491 ms
3,476 KB |
testcase_89 | AC | 512 ms
3,620 KB |
testcase_90 | AC | 504 ms
3,524 KB |
testcase_91 | AC | 486 ms
3,564 KB |
testcase_92 | AC | 503 ms
3,568 KB |
testcase_93 | AC | 481 ms
3,548 KB |
testcase_94 | AC | 473 ms
3,472 KB |
testcase_95 | AC | 493 ms
3,540 KB |
testcase_96 | AC | 509 ms
3,552 KB |
testcase_97 | AC | 514 ms
3,624 KB |
testcase_98 | AC | 499 ms
3,584 KB |
testcase_99 | AC | 506 ms
3,480 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/twosat> using namespace std; using ll = long long; template <class T, class F> T UpperBound(T i0, T i1, F f) { while (i0 < i1) { T i = i0 + (i1 - i0) / 2; if (f(i)) i0 = i + 1; else i1 = i; } return i0; } constexpr int N = 2048, M = 256, K = 1; int a[N][6]; int main() { mt19937_64 rnd; int sc = 0; for (int k = 0; k < K; k++) { for (int i = 0; i < N; i++) { for (int h = 0; h < 6; h++) { if (K == 1) { cin >> a[i][h]; } else { a[i][h] = rnd() % (h < 3 ? 256 : 2); } } } int r[M] = {}; vector<bool> v; int s = UpperBound<int>(1, 500 + 1, [&](auto s) { atcoder::two_sat ts(M); for (int i = 0; i < s; i++) { ts.add_clause(a[i][0], a[i][3], a[i][1], a[i][4]); } int b = ts.satisfiable(); if (b) v = ts.answer(); return b; }) - 1; for (int l = 0; l < 10000; l++) { int s0 = s; atcoder::two_sat ts(M); for (int i = 0; i < s; i++) { ts.add_clause(a[i][0], a[i][3], a[i][1], a[i][4]); } for (int i = s; i < N; i++) { ts.add_clause(a[i][0], a[i][3], a[i][1], a[i][4]); int b = ts.satisfiable(); if (b) v = ts.answer(), s = i + 1; else break; } if (s == s0) { for (int i = 0; i < s + 1; i++) { int h0 = 2, h1 = rnd() % 2; swap(a[i][h0], a[i][h1]); swap(a[i][h0 + 3], a[i][h1 + 3]); } } else { swap(a[s][rnd() % 2], a[s][2]); } } for (int l = 0; l < 100000; l++) { int x[M] = {}; for (int i = 0; i < s; i++) { int c = 0; for (int h = 0; h < 3; h++) { c += r[a[i][h]] == a[i][h + 3]; } if (c == 1) { for (int h = 0; h < 3; h++) { if (r[a[i][h]] == a[i][h + 3]) { x[a[i][h]]++; break; } } } } int b = 0; for (int h = 0; h < 3; h++) { if (x[a[s][h]] == 0) { r[a[s][h]] = a[s][h + 3]; s++; b = 1; break; } } if (b == 0) { for (int i = 0; i < s; i++) { int c = 0; for (int h = 0; h < 3; h++) { c += r[a[i][h]] == a[i][h + 3]; } if (c > 1) { int h1 = rnd() % 3; for (int h0 = 0; h0 < 3; h0++) { int h = (h0 + h1) % 3; if (x[a[i][h]] == 0) r[a[i][h]] ^= 1; } break; } } } } for (int j = 0; j < M; j++) { r[j] = v[j]; } if (K == 1) { for (int j = M - 1; j >= 0; j--) { cout << r[j]; } cout << endl; } else { int s = N; for (int i = 0; i < N; i++) { int b = 0; for (int h = 0; h < 3; h++) { if (r[a[i][h]] == a[i][h + 3]) { b = 1; break; } } if (b == 0) { s = i; break; } } cout << s << '\n'; sc += s; } } if (K > 1) { cout << sc * 100 / K << '\n'; } return 0; }