結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 13 ms
5,376 KB
testcase_02 AC 14 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 138 ms
6,016 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 98 ms
5,888 KB
testcase_11 AC 87 ms
5,632 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 51 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 87 ms
5,632 KB
testcase_21 AC 56 ms
5,376 KB
testcase_22 AC 137 ms
5,888 KB
testcase_23 WA -
testcase_24 AC 291 ms
6,144 KB
testcase_25 WA -
testcase_26 AC 150 ms
6,528 KB
testcase_27 AC 51 ms
6,144 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 13 ms
5,376 KB
testcase_31 AC 12 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]])) == 0){
              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