結果
問題 | No.408 五輪ピック |
ユーザー |
![]() |
提出日時 | 2016-08-05 23:05:51 |
言語 | C++11 (gcc 13.3.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,470 bytes |
コンパイル時間 | 907 ms |
コンパイル使用メモリ | 93,748 KB |
実行使用メモリ | 817,944 KB |
最終ジャッジ日時 | 2024-11-07 00:51:13 |
合計ジャッジ時間 | 4,412 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 MLE * 1 -- * 26 |
ソースコード
#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]; int 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 >= 6) {//集計 if (have_come[5][1] == true) { cout << "YES" << endl; return 0; } cout << "NO" << endl; return 0; } for (int i = 0;i < path[now_here].size();++i) { if (path[now_here][i] != before_come) { have_come[score+1][path[now_here][i]] = true; hoge.push(make_tuple(path[now_here][i], now_here, score + 1)); } } } //そもそも道すらなかった場合 if (have_come[5][1] == true) { cout << "YES" << endl; return 0; } cout << "NO" << endl; return 0; }