結果

問題 No.408 五輪ピック
ユーザー btkbtk
提出日時 2016-08-04 11:53:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 1,400 bytes
コンパイル時間 1,926 ms
コンパイル使用メモリ 168,712 KB
実行使用メモリ 5,504 KB
最終ジャッジ日時 2024-04-24 15:17:50
合計ジャッジ時間 3,338 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 15 ms
5,376 KB
testcase_06 AC 22 ms
5,376 KB
testcase_07 AC 14 ms
5,376 KB
testcase_08 AC 10 ms
5,376 KB
testcase_09 AC 11 ms
5,376 KB
testcase_10 AC 17 ms
5,376 KB
testcase_11 AC 16 ms
5,376 KB
testcase_12 AC 14 ms
5,376 KB
testcase_13 AC 15 ms
5,376 KB
testcase_14 AC 8 ms
5,376 KB
testcase_15 AC 16 ms
5,376 KB
testcase_16 AC 15 ms
5,376 KB
testcase_17 AC 14 ms
5,376 KB
testcase_18 AC 15 ms
5,376 KB
testcase_19 AC 16 ms
5,376 KB
testcase_20 AC 13 ms
5,376 KB
testcase_21 AC 8 ms
5,376 KB
testcase_22 AC 21 ms
5,376 KB
testcase_23 AC 21 ms
5,376 KB
testcase_24 AC 68 ms
5,376 KB
testcase_25 AC 13 ms
5,376 KB
testcase_26 AC 30 ms
5,504 KB
testcase_27 AC 127 ms
5,376 KB
testcase_28 AC 12 ms
5,376 KB
testcase_29 AC 13 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

struct I{I(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef vector<int> V;
typedef vector<V> Graph;
inline unsigned xorshift(void) {
  static unsigned y = 114514;
  y = y ^ (y << 13); y = y ^ (y >> 17);
  return y = y ^ (y << 5);
}
inline int myrand(int mod){
    return (int)(xorshift()%mod);
}
bool used[16][20000];
int color[20000];
int ord[]={0,1,2,4,8,3,5,6,9,10,12,7,11,13,14,15};
bool test(Graph& g){
    int N=g.size();
    for(int b=1;b<16;b++)for(int i=1;i<N;i++)used[b][i]=false;
    for(int i=1;i<N;i++)color[i]=myrand(4);
    for(auto &v:g[0])used[1<<color[v]][v]=true;
    for(int bb=1,b;bb<16;bb++){
        b=ord[bb];
        for(int i=1;i<N;i++)
            if(used[b][i])
                for(auto &it:g[i]){
                    int c=1<<color[it];
                    if(!(b&c))
                        used[b|c][it]=true;
                }    
    }
    for(auto &it:g[0])if(used[15][it])return true;
    return false;
}

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> A(M),B(M);
    for(int i=0;i<M;A[i]--,B[i]--,i++)cin>>A[i]>>B[i];
    Graph g(N);
    for(int i=0;i<M;i++){
        if(B[i]!=0)g[A[i]].push_back(B[i]);
        if(A[i]!=0)g[B[i]].push_back(A[i]);
    }

    for(int i=0;i<50;i++)if(test(g)){
            cout<<"YES"<<endl;
            return 0;
        }
    
    cout<<"NO"<<endl;
    return 0;
}
0