結果

問題 No.408 五輪ピック
ユーザー haruteruharuteru
提出日時 2016-08-09 12:00:16
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 696 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 60,536 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 22:37:11
合計ジャッジ時間 1,810 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

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

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

int main()
{
    memset(memo, -1, sizeof(memo));

    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