結果

問題 No.408 五輪ピック
ユーザー どららどらら
提出日時 2016-08-06 01:39:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,456 bytes
コンパイル時間 669 ms
コンパイル使用メモリ 83,376 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-04-24 17:09:10
合計ジャッジ時間 13,164 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,248 KB
testcase_01 AC 13 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 13 ms
5,376 KB
testcase_04 AC 13 ms
5,376 KB
testcase_05 AC 462 ms
6,144 KB
testcase_06 WA -
testcase_07 AC 484 ms
6,144 KB
testcase_08 AC 362 ms
6,016 KB
testcase_09 AC 418 ms
5,888 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 576 ms
6,400 KB
testcase_13 AC 453 ms
6,144 KB
testcase_14 WA -
testcase_15 AC 458 ms
6,144 KB
testcase_16 AC 506 ms
6,144 KB
testcase_17 AC 575 ms
6,272 KB
testcase_18 AC 645 ms
6,144 KB
testcase_19 AC 703 ms
6,400 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1,388 ms
6,656 KB
testcase_24 AC 512 ms
6,144 KB
testcase_25 AC 442 ms
6,144 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 458 ms
5,888 KB
testcase_29 AC 455 ms
5,888 KB
testcase_30 AC 12 ms
5,376 KB
testcase_31 AC 13 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

vector<int> v[20005];
int A[50005], B[50005];

int color[20005];
int dp[(1<<4)][20005];


int main(){
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  rep(i,M){
    cin >> A[i] >> B[i];
    v[A[i]].push_back(B[i]);
    v[B[i]].push_back(A[i]);
  }

  bool ret = false;
  rep(t,200){
    rep(i,N+1) color[i] = rand()%4;
    rep(i,(1<<4)) rep(j,20005) dp[i][j] = 0;
    rep(i,v[1].size()){
      dp[(1<<(color[v[1][i]]))][v[1][i]] = 1;
    }
    rep(i,(1<<4)){
      rep(j,N+1){
        if(dp[i][j] == 1){
          rep(k,v[j].size()){
            if(v[j][k] == 1) continue;
            if(i | (1<<(color[v[j][k]])) != i){
              dp[i | (1<<(color[v[j][k]]))][v[j][k]] = 1;
            }
          }
        }
      }
    }
    rep(i,N+1){
      if(dp[(1<<4)-1][i] == 1){
        rep(j,v[i].size()) if(v[i][j] == 1) ret = true;
      }
    }
  }

  if(ret) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

0