結果

問題 No.408 五輪ピック
ユーザー parukiparuki
提出日時 2016-08-05 22:35:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,090 bytes
コンパイル時間 1,692 ms
コンパイル使用メモリ 165,240 KB
実行使用メモリ 7,752 KB
最終ジャッジ日時 2024-04-24 15:49:35
合計ジャッジ時間 38,287 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
6,656 KB
testcase_01 AC 105 ms
6,784 KB
testcase_02 AC 105 ms
6,528 KB
testcase_03 AC 106 ms
6,784 KB
testcase_04 AC 110 ms
6,784 KB
testcase_05 AC 3,654 ms
7,168 KB
testcase_06 AC 529 ms
7,424 KB
testcase_07 AC 457 ms
7,424 KB
testcase_08 AC 817 ms
6,944 KB
testcase_09 AC 344 ms
7,296 KB
testcase_10 AC 390 ms
7,212 KB
testcase_11 AC 352 ms
7,064 KB
testcase_12 AC 423 ms
7,480 KB
testcase_13 AC 3,057 ms
7,296 KB
testcase_14 AC 241 ms
6,912 KB
testcase_15 AC 3,928 ms
7,296 KB
testcase_16 AC 2,346 ms
7,296 KB
testcase_17 AC 789 ms
7,424 KB
testcase_18 AC 428 ms
7,424 KB
testcase_19 AC 443 ms
7,552 KB
testcase_20 AC 358 ms
7,040 KB
testcase_21 AC 247 ms
6,912 KB
testcase_22 AC 541 ms
7,424 KB
testcase_23 TLE -
testcase_24 AC 1,582 ms
7,552 KB
testcase_25 AC 2,216 ms
7,296 KB
testcase_26 AC 563 ms
7,752 KB
testcase_27 AC 2,231 ms
7,296 KB
testcase_28 AC 1,341 ms
7,264 KB
testcase_29 AC 1,343 ms
7,256 KB
testcase_30 AC 105 ms
6,656 KB
testcase_31 AC 107 ms
6,656 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, 1000){
        MEM(vis, 0);
        rep(i, N)C[i] = 1<<(rand()%5);
        dfs(0, C[0]);
    }

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