結果

問題 No.5005 3-SAT
ユーザー merom686
提出日時 2022-04-29 16:19:06
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,002 ms / 2,000 ms
コード長 2,061 bytes
コンパイル時間 1,902 ms
実行使用メモリ 3,640 KB
スコア 87,576
最終ジャッジ日時 2022-04-29 16:21:33
合計ジャッジ時間 107,777 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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++) {
        auto t0 = chrono::high_resolution_clock::now();

        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);
                }
            }
        }

        array<char, M> r = {}, t = {};
        int s = 0;
        while (1) {
            for (int i = 0; i < N; i++) {
                int b = 0;
                for (int h = 0; h < 3; h++) {
                    if (t[a[i][h]] == a[i][h + 3]) {
                        b = 1;
                        break;
                    }
                }
                if (b == 0) {
                    if (i > s) {
                        s = i;
                        r = t;
                    }
                    int h = rnd() % 3;
                    t[a[i][h]] ^= 1;
                    break;
                }
            }
            auto t1 = chrono::high_resolution_clock::now();
            if (chrono::duration_cast<chrono::milliseconds>(t1 - t0).count() >= 1000) break;
        }

        if (k == 0) {
            for (int j = M - 1; j >= 0; j--) {
                cout << (int)r[j];
            }
            cout << endl;
        }
        if (K != 1) {
            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;
}
0