結果
| 問題 | No.408 五輪ピック |
| コンテスト | |
| ユーザー |
kurenai3110
|
| 提出日時 | 2016-10-18 18:35:08 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,120 bytes |
| 記録 | |
| コンパイル時間 | 435 ms |
| コンパイル使用メモリ | 77,808 KB |
| 最終ジャッジ日時 | 2026-05-16 14:28:19 |
| 合計ジャッジ時間 | 1,075 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:10:17: error: 'INT32_MAX' was not declared in this scope
10 | int cnt=INT32_MAX;
| ^~~~~~~~~
main.cpp:5:1: note: 'INT32_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
4 | #include <queue>
+++ |+#include <cstdint>
5 | using namespace std;
ソースコード
#include <iostream>
#include<algorithm>
#include <vector>
#include <queue>
using namespace std;
int N, M;
struct Node {
int cnt=INT32_MAX;
int from;
int from_cnt = 0;
};
int main()
{
cin >> N >> M;
vector<vector<int> > G(N+1);
vector<Node> node(N + 1); node[1].cnt = 0;
for (int i = 0; i < M; i++) {
int a, b; cin >> a >> b;
G[a].push_back(b);
G[b].push_back(a);
}
queue<int> que;
for (int i = 0; i < G[1].size(); i++) {
que.push(G[1][i]);
node[G[1][i]].from = 1;
node[G[1][i]].from_cnt++;
node[G[1][i]].cnt = node[1].cnt + 1;
}
bool flag = false;
while (!que.empty()) {
int p = que.front(); que.pop();
for (int i = 0; i < G[p].size(); i++) {
if (node[p].cnt == 3)continue;
if (node[G[p][i]].cnt == 2 && node[p].cnt == 2 && (node[G[p][i]].from!=node[p].from || (node[G[p][i]].from_cnt>1 || node[p].from_cnt>1))) flag = true;
if (node[G[p][i]].cnt < node[p].cnt)continue;
que.push(G[p][i]);
node[G[p][i]].from = p;
node[G[p][i]].from_cnt++;
node[G[p][i]].cnt = node[p].cnt + 1;
}
}
if (flag)cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}
kurenai3110