結果

問題 No.5005 3-SAT
ユーザー 👑 Nachia
提出日時 2022-04-29 14:25:13
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,362 bytes
コンパイル時間 1,726 ms
実行使用メモリ 6,952 KB
スコア 739
最終ジャッジ日時 2022-04-29 14:25:20
合計ジャッジ時間 6,620 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <array>
#include <atcoder/modint>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using m32 = atcoder::static_modint<998244353>;

const int N = 2048;

struct Constraint{
    pair<int,int> a[3];
};

vector<array<array<int, 2>, 3>> A;
vector<int> ans;

int main(){
    A.resize(N);
    rep(i,N) rep(c,2) rep(t,3) cin >> A[i][t][c];
    rep(i,N) rep(t,3) A[i][t][0] = N - 1 - A[i][t][0];
    rep(i,N) sort(A[i].begin(), A[i].end());
    rep(i,N) rep(t,2){
        if(A[i][t][0] == A[i][t+1][0] && A[i][t][1] != A[i][t+1][1]){
            A[i][t][0] = A[i][t+1][0] = N;
            A[i][t][1] = A[i][t+1][1] = -1;
        }
    }

    ans.assign(N + 1, -1);
    rep(i,N){
        bool ok = false;
        rep(t,3) if(ans[A[i][t][0]] == A[i][t][1]) ok = true;
        if(ok) break;
        rep(t,3) if(ans[A[i][t][0]] == -1){
            ans[A[i][t][0]] = A[i][t][1];
            break;
        }
    }

    rep(i,N) if(ans[i] == -1) ans[i] = 0;
    rep(i,N) cout << ans[i];
    cout << endl;

    return 0;
}

struct ios_do_not_sync{
    ios_do_not_sync(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }
} ios_do_not_sync_instance;
0