結果

問題 No.408 五輪ピック
ユーザー parukiparuki
提出日時 2016-08-05 22:36:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,157 ms / 5,000 ms
コード長 1,089 bytes
コンパイル時間 1,504 ms
コンパイル使用メモリ 167,908 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2023-08-06 21:19:48
合計ジャッジ時間 10,192 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
6,564 KB
testcase_01 AC 29 ms
6,380 KB
testcase_02 AC 29 ms
6,564 KB
testcase_03 AC 29 ms
6,444 KB
testcase_04 AC 30 ms
6,448 KB
testcase_05 AC 777 ms
6,940 KB
testcase_06 AC 89 ms
7,100 KB
testcase_07 AC 82 ms
7,272 KB
testcase_08 AC 181 ms
6,860 KB
testcase_09 AC 76 ms
6,944 KB
testcase_10 AC 71 ms
7,184 KB
testcase_11 AC 66 ms
6,864 KB
testcase_12 AC 80 ms
7,248 KB
testcase_13 AC 644 ms
7,200 KB
testcase_14 AC 47 ms
6,608 KB
testcase_15 AC 838 ms
7,060 KB
testcase_16 AC 497 ms
7,120 KB
testcase_17 AC 174 ms
7,076 KB
testcase_18 AC 91 ms
7,160 KB
testcase_19 AC 85 ms
7,260 KB
testcase_20 AC 63 ms
6,912 KB
testcase_21 AC 49 ms
6,600 KB
testcase_22 AC 87 ms
7,112 KB
testcase_23 AC 1,157 ms
7,288 KB
testcase_24 AC 304 ms
7,408 KB
testcase_25 AC 481 ms
7,076 KB
testcase_26 AC 100 ms
7,552 KB
testcase_27 AC 484 ms
7,276 KB
testcase_28 AC 264 ms
6,892 KB
testcase_29 AC 262 ms
6,968 KB
testcase_30 AC 29 ms
6,356 KB
testcase_31 AC 30 ms
6,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

const int N_MAX = 20001;
int N, M, C[N_MAX], vis[N_MAX][1 << 5], ok = 0;
vi G[N_MAX];

void dfs(int u, int S){
    if(vis[u][S]++)return;

    if(S == (1 << 5) - 1){
        each(v, G[u])if(v == 0)ok = 1;
        return;
    }
    each(v, G[u]) if(!(C[v]&S)) dfs(v, S | C[v]);
}

int main(){
    cin >> N >> M;
    rep(i, M){
        int A, B;
        scanf("%d%d", &A, &B);
        G[--A].push_back(--B);
        G[B].push_back(A);
    }

    rep(iter, 250){
        MEM(vis, 0);
        rep(i, N)C[i] = 1<<(rand()%5);
        dfs(0, C[0]);
    }

    puts(ok ? "YES" : "NO");
}
0