結果

問題 No.408 五輪ピック
ユーザー t98slidert98slider
提出日時 2023-01-27 14:26:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 971 ms / 5,000 ms
コード長 1,332 bytes
コンパイル時間 1,880 ms
コンパイル使用メモリ 175,172 KB
実行使用メモリ 4,596 KB
最終ジャッジ日時 2023-09-10 09:42:11
合計ジャッジ時間 17,592 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 965 ms
4,380 KB
testcase_02 AC 964 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 14 ms
4,376 KB
testcase_06 AC 966 ms
4,384 KB
testcase_07 AC 18 ms
4,376 KB
testcase_08 AC 10 ms
4,376 KB
testcase_09 AC 10 ms
4,380 KB
testcase_10 AC 967 ms
4,376 KB
testcase_11 AC 968 ms
4,376 KB
testcase_12 AC 13 ms
4,376 KB
testcase_13 AC 13 ms
4,376 KB
testcase_14 AC 968 ms
4,380 KB
testcase_15 AC 13 ms
4,376 KB
testcase_16 AC 14 ms
4,376 KB
testcase_17 AC 13 ms
4,380 KB
testcase_18 AC 13 ms
4,388 KB
testcase_19 AC 15 ms
4,380 KB
testcase_20 AC 967 ms
4,376 KB
testcase_21 AC 966 ms
4,380 KB
testcase_22 AC 967 ms
4,424 KB
testcase_23 AC 22 ms
4,596 KB
testcase_24 AC 971 ms
4,540 KB
testcase_25 AC 12 ms
4,380 KB
testcase_26 AC 967 ms
4,532 KB
testcase_27 AC 967 ms
4,380 KB
testcase_28 AC 10 ms
4,380 KB
testcase_29 AC 10 ms
4,380 KB
testcase_30 AC 966 ms
4,376 KB
testcase_31 AC 966 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

unsigned long long xor64(){
    static unsigned long long x = 88172645463325252LL;
    x ^= (x << 13);
    x ^= (x >> 7);
    return (x ^= (x << 17));
}

//頂点数Lの単純パスを見つける
bool color_coding(vector<vector<int>> &g, int L){
    int n = g.size();
    vector<int> a(n);
    vector<vector<bool>> dp(1 << L, vector<bool>(n));
    for(int i = 0; i < n; i++){
        a[i] = 1 << (xor64() % L);
    }
    for(auto &&u:g[0]) dp[a[u]][u] = true;
    for(int S = 1; S < (1 << L); S++){
        for(int v = 1; v < n; v++){
            if(!dp[S][v])continue;
            for(auto &&u:g[v]){
                if(!u || (S & a[u]))continue;
                dp[S | a[u]][u] = true;
            }
        }
    }
    for(auto &&u:g[0]) if(dp.back()[u])return true;
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    clock_t finish = clock() + CLOCKS_PER_SEC / 1000 * 960;
    int n, m, u, v;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for(int i = 0; i < m; i++){
        cin >> u >> v;
        g[--u].push_back(--v);
        g[v].push_back(u);
    }
    while(clock() <= finish){
        if(color_coding(g, 4)){
            cout << "YES" << '\n';
            return 0;
        }
    }
    cout << "NO" << '\n';
}
0