結果
問題 |
No.408 五輪ピック
|
ユーザー |
![]() |
提出日時 | 2016-08-05 23:16:37 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,463 bytes |
コンパイル時間 | 971 ms |
コンパイル使用メモリ | 95,556 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-07 01:41:42 |
合計ジャッジ時間 | 2,647 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 WA * 4 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <algorithm> #include <utility> #include <functional> #include <cstring> #include <queue> #include <stack> #include <math.h> #include <iterator> #include <vector> #include <string> #include <set> #include <math.h> #include <iostream> #include<map> #include <stdlib.h> #include <list> #include <typeinfo> #include <list> #include <set> #include <iomanip> using namespace std; #define MAX_MOD 1000000007 #define REP(i,n) for(int i = 0;i < n;++i) vector<int> path[30000]; bool have_come[10][30000] = {}; int main() { int n, m; cin >> n >> m; REP(i, m) { int a, b; cin >> a >> b; path[a].push_back(b); path[b].push_back(a); } queue<tuple<int,int,int>> hoge; hoge.push(make_tuple(1,1,0)); have_come[0][1] = true; while (hoge.empty() == false) { int now_here = get<0>(hoge.front()); int before_come = get<1>(hoge.front()); int score = get<2>(hoge.front()); hoge.pop(); if (score >= 3) {//5を超えた cout << "NO" << endl; return 0; } for (int i = 0;i < path[now_here].size();++i) { if (path[now_here][i] != before_come) { if (have_come[score + 1][path[now_here][i]] == false) { if (have_come[4 - score][path[now_here][i]] == true) { cout << "YES" << endl; return 0; } have_come[score + 1][path[now_here][i]] = true; hoge.push(make_tuple(path[now_here][i], now_here, score + 1)); } } } } cout << "NO" << endl; return 0; }