結果

問題 No.408 五輪ピック
ユーザー btkbtk
提出日時 2016-08-04 11:52:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,401 bytes
コンパイル時間 1,862 ms
コンパイル使用メモリ 168,456 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 15:17:43
合計ジャッジ時間 4,364 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 RE -
testcase_07 RE -
testcase_08 AC 11 ms
5,376 KB
testcase_09 AC 11 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 18 ms
5,376 KB
testcase_13 AC 15 ms
5,376 KB
testcase_14 AC 12 ms
5,376 KB
testcase_15 AC 15 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 17 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 11 ms
5,376 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 14 ms
5,376 KB
testcase_26 RE -
testcase_27 AC 245 ms
5,376 KB
testcase_28 AC 13 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][10000];
int color[10000];
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<100;i++)if(test(g)){
            cout<<"YES"<<endl;
            return 0;
        }
    
    cout<<"NO"<<endl;
    return 0;
}
0