結果

問題 No.8092 3-2-SAT
ユーザー houren
提出日時 2022-04-01 21:50:43
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 973 bytes
コンパイル時間 1,609 ms
コンパイル使用メモリ 172,068 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-11-20 08:56:31
合計ジャッジ時間 4,282 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<vector<int>> q(m,vector<int>(4));
    rep(i,m){
        rep(j,4) cin >> q[i][j];
        q[i][0]--;
        q[i][1]--;
    }
    vector<int> a = {1,2,3};
    do{
        bool ans = true;
        rep(i,m){
            if(a[q[i][0]]!=q[i][2] && a[q[i][1]]!=q[i][3]){
                ans = false;
                break;
            }
        }
        if(ans){
            rep(i,3) cout << a[i] << ' ';
            cout << '\n';
            return 0;
        }
    }while(next_permutation(all(a)));
    cout << -1 << '\n';
    return 0;
}
0