結果
| 問題 |
No.408 五輪ピック
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-08-05 22:43:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 342 ms / 5,000 ms |
| コード長 | 823 bytes |
| コンパイル時間 | 1,912 ms |
| コンパイル使用メモリ | 163,476 KB |
| 実行使用メモリ | 54,272 KB |
| 最終ジャッジ日時 | 2024-11-07 00:31:11 |
| 合計ジャッジ時間 | 4,793 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
コンパイルメッセージ
main.cpp: In function ‘bool solve()’:
main.cpp:12:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d %d", &u, &v);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> g[20202];
bitset<20202> path[20202]; // last
bool solve() {
cin >> n >> m;
for (int i = 0; i < m; i++) {
int u, v;
scanf("%d %d", &u, &v);
u--;
v--;
g[u].push_back(v);
g[v].push_back(u);
}
for (int i : g[0]) {
for (int j : g[i]) if (j != 0) {
path[j][i] = true;
}
}
for (int i = 1; i < n; i++) {
for (int j : g[i]) if (j != 0) {
bool p1 = path[i][j];
bool p2 = path[j][i];
path[i][j] = false;
path[j][i] = false;
if (path[i].count() == 1 && path[j].count() == 1) {
if ((path[i] & path[j]).none()) return true;
} else if (path[i].count() >= 1 && path[j].count() >= 1) {
return true;
}
path[i][j] = p1;
path[j][i] = p2;
}
}
return false;
}
int main() {
puts(solve() ? "YES" : "NO");
}