結果

問題 No.408 五輪ピック
ユーザー tottoripapertottoripaper
提出日時 2016-10-20 21:40:43
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,056 bytes
コンパイル時間 1,126 ms
コンパイル使用メモリ 160,480 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 05:43:13
合計ジャッジ時間 2,268 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 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 WA -
testcase_06 AC 9 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 8 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 9 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 6 ms
5,376 KB
testcase_21 AC 4 ms
5,376 KB
testcase_22 AC 8 ms
5,376 KB
testcase_23 AC 14 ms
5,376 KB
testcase_24 AC 10 ms
5,376 KB
testcase_25 WA -
testcase_26 AC 16 ms
5,376 KB
testcase_27 AC 10 ms
5,376 KB
testcase_28 AC 8 ms
5,376 KB
testcase_29 AC 8 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int N, M;
vector<int> G[20000];
bool used[20000];

int can(int u, int n){
    bool f = false;
    for(int v : G[u]){
        if(v == 0 && n == 5){return true;}

        if(!used[v]){
            used[v] = true;
            // std::cout << "-> " << v << std::endl;
            f = f || can(v, n + 1);
        }
    }

    return f;
}

int main(){
    //*
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    /*/
      /*/

    std::cin >> N >> M;

    for(int i=0;i<M;++i){
        int A, B;
        std::cin >> A >> B;

        --A; --B;

        G[A].emplace_back(B);
        G[B].emplace_back(A);
    }

    used[0] = true;
    bool f = can(0, 1);

    if(f){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
}
0