結果
問題 |
No.408 五輪ピック
|
ユーザー |
![]() |
提出日時 | 2016-08-07 04:47:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,400 bytes |
コンパイル時間 | 858 ms |
コンパイル使用メモリ | 66,316 KB |
実行使用メモリ | 12,068 KB |
最終ジャッジ日時 | 2024-11-07 04:37:54 |
合計ジャッジ時間 | 9,771 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 TLE * 1 -- * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:15:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | int a, b; scanf("%d %d", &a, &b); | ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <cstdio> using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) int n, m; vector<int> g[20001]; // bool memo[20001][20001]; int main(void){ cin >> n >> m; rep(i, m){ int a, b; scanf("%d %d", &a, &b); a--; b--; g[a].push_back(b); g[b].push_back(a); // memo[a][b] = memo[b][a] = true; } //1 - u - vとなるような辺を見つける vector<pair<int, int> > d; for(int u : g[0]){ for (int v : g[u]){ //頂点に戻るようなものは入れない if(v != 0) d.push_back(make_pair(u, v)); } } for (int i = 0; i < d.size() - 1; ++i){ for (int j = i + 1; j < d.size(); ++j){ if(d[i].first != d[j].first && d[i].first != d[j].second && d[i].second != d[j].first && d[i].second != d[j].second){ for (int tmp : g[d[i].second]){ if(tmp == d[j].second){ printf("YES\n"); return 0; } } /* if(memo[d[i].second][d[j].second]){ printf("YES\n"); return 0; } */ } } } printf("NO\n"); return 0; }