結果
| 問題 | No.583 鉄道同好会 |
| コンテスト | |
| ユーザー |
mzkr
|
| 提出日時 | 2019-06-23 23:39:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,047 bytes |
| 記録 | |
| コンパイル時間 | 841 ms |
| コンパイル使用メモリ | 79,580 KB |
| 実行使用メモリ | 13,396 KB |
| 最終ジャッジ日時 | 2024-12-29 18:07:46 |
| 合計ジャッジ時間 | 26,350 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 TLE * 8 |
ソースコード
#include <iostream>
#include <tuple>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long int;
using P = tuple<int, int, bool>;
int N, M;
vector<P> WAY;
bool dfs(int p, int num) {
// cout << num << endl;
for (auto&& w: WAY) {
int& a = get<0>(w);
int& b = get<1>(w);
bool& c = get<2>(w);
if (a != p || !c) continue;
c = false;
if (dfs(b, num+1)) return true;
c = true;
}
for (auto&& w: WAY) {
int& a = get<0>(w);
int& b = get<1>(w);
bool& c = get<2>(w);
if (b != p || !c) continue;
c = false;
if (dfs(a, num+1)) return true;
c = true;
}
return num == M;
}
int main() {
cin >> N >> M;
for (int i = 0; i < M; ++i) {
int Sa, Sb;
cin >> Sa >> Sb;
WAY.push_back(make_tuple(Sa, Sb, true));
}
int a, b;
bool c;
for (auto&& w: WAY) {
int a, b;
bool c;
tie(a, b, c) = w;
}
for (int i = 0; i < N; ++i) {
if (dfs(i, 0)) {
cout << "YES" << endl;
return 0;
}
}
cout << "NO" << endl;
return 0;
}
mzkr