結果

問題 No.408 五輪ピック
ユーザー haruteruharuteru
提出日時 2016-08-09 12:57:19
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 652 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 60,372 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2024-04-24 22:56:09
合計ジャッジ時間 8,216 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 24 ms
5,376 KB
testcase_06 AC 17 ms
5,376 KB
testcase_07 AC 24 ms
5,376 KB
testcase_08 AC 20 ms
5,376 KB
testcase_09 AC 21 ms
5,376 KB
testcase_10 AC 16 ms
5,376 KB
testcase_11 AC 16 ms
5,376 KB
testcase_12 AC 28 ms
5,376 KB
testcase_13 AC 23 ms
5,376 KB
testcase_14 AC 7 ms
5,376 KB
testcase_15 AC 24 ms
5,376 KB
testcase_16 AC 27 ms
5,376 KB
testcase_17 AC 29 ms
5,376 KB
testcase_18 AC 28 ms
5,376 KB
testcase_19 AC 31 ms
5,376 KB
testcase_20 AC 9 ms
5,376 KB
testcase_21 AC 6 ms
5,376 KB
testcase_22 AC 14 ms
5,376 KB
testcase_23 AC 30 ms
5,376 KB
testcase_24 AC 21 ms
5,376 KB
testcase_25 AC 94 ms
5,376 KB
testcase_26 AC 34 ms
5,376 KB
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <memory.h>
using namespace std;

int N, M;
vector<int> A[20000+1];
int memo[20000+1];

int solve(int n, int len)
{
    if (len == 5) {
        return n;
    }
    if (memo[n] == 1) {
        return 0;
    }
    memo[n] = 1;
    for (int i = 0; i < A[n].size(); i++) {
        if (solve(A[n][i], len+1) == 1) {
            return 1;
        }
    }
    memo[n] = 0;
    return 0;
}

int main()
{
    cin >> N;
    cin >> M;
    while (M--) {
        int a, b;
        cin >> a;
        cin >> b;
        A[a].push_back(b);
        A[b].push_back(a);
    }
    cout << (solve(1, 0)? "YES": "NO") << endl;
}
0