結果
問題 |
No.408 五輪ピック
|
ユーザー |
![]() |
提出日時 | 2016-10-20 21:33:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,286 bytes |
コンパイル時間 | 1,598 ms |
コンパイル使用メモリ | 160,356 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2024-11-22 16:52:29 |
合計ジャッジ時間 | 3,124 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 WA * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) using ll = long long; using P = std::tuple<int,int>; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; int N, M; vector<int> G[20000]; bool used[20000]; int can(int u, int p, int n){ bool f = false; for(int v : G[u]){ if(v != p && used[v] && n == 5){return true;} if(!used[v]){ used[v] = true; // std::cout << "-> " << v << std::endl; f = f || can(v, u, n + 1); } } return f; } int main(){ //* std::cin.tie(nullptr); std::ios::sync_with_stdio(false); /*/ /*/ std::cin >> N >> M; for(int i=0;i<M;++i){ int A, B; std::cin >> A >> B; --A; --B; G[A].emplace_back(B); G[B].emplace_back(A); } bool f = false; for(int i=0;i<N;++i){ if(!used[i]){ // std::cout << i << std::endl; used[i] = true; f = f || can(i, -1, 1); // std::cout << i << ", " << f << std::endl; } } if(f){ std::cout << "YES" << std::endl; }else{ std::cout << "NO" << std::endl; } }