結果
問題 |
No.583 鉄道同好会
|
ユーザー |
![]() |
提出日時 | 2019-01-31 13:38:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 687 bytes |
コンパイル時間 | 1,947 ms |
コンパイル使用メモリ | 171,124 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-14 07:05:56 |
合計ジャッジ時間 | 3,684 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 WA * 3 |
ソースコード
#include <bits/stdc++.h> using namespace std; int n, m; const int MAX = 510; vector<int> G[MAX]; vector<bool> used(MAX); bool dfs(int now, int cnt){ if(cnt == m) return true; used[now] = true; for(int i = 0; i < G[now].size(); i++){ if(!used[G[now][i]]){ return dfs(G[now][i], cnt + 1); } } return false; } int main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m; for(int i = 0; i < m; i++){ int a, b; cin >> a >> b; G[a].push_back(b); G[b].push_back(a); } if(dfs(0, 0)){ cout << "YES" << endl; }else{ cout << "NO" << endl; } return 0; }