結果

問題 No.583 鉄道同好会
ユーザー tokizotokizo
提出日時 2019-01-31 13:38:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 687 bytes
コンパイル時間 2,251 ms
コンパイル使用メモリ 167,328 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 17:30:31
合計ジャッジ時間 3,494 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 7 ms
6,940 KB
testcase_12 AC 8 ms
6,940 KB
testcase_13 AC 9 ms
6,944 KB
testcase_14 AC 9 ms
6,940 KB
testcase_15 AC 10 ms
6,944 KB
testcase_16 AC 19 ms
6,944 KB
testcase_17 AC 21 ms
6,944 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0