結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 1 ms
5,376 KB
testcase_05 AC 9 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 13 ms
5,376 KB
testcase_08 AC 9 ms
5,376 KB
testcase_09 AC 10 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 14 ms
5,376 KB
testcase_13 AC 10 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 10 ms
5,376 KB
testcase_16 AC 10 ms
5,376 KB
testcase_17 AC 12 ms
5,376 KB
testcase_18 AC 13 ms
5,376 KB
testcase_19 AC 14 ms
5,504 KB
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 13 ms
5,376 KB
testcase_24 AC 10 ms
5,376 KB
testcase_25 AC 10 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
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 2 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 p, int n){
    bool f = false;
    for(int v : G[u]){
        if(v != p && used[v] && n == 5){return true;}

        if(!used[v]){
            used[v] = true;
            // std::cout << "-> " << v << std::endl;
            f = f || can(v, u, 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);
    }
    
    bool f = false;
    for(int i=0;i<N;++i){
        if(!used[i]){
            // std::cout << i << std::endl;
            used[i] = true;
            f = f || can(i, -1, 1);
            // std::cout << i << ", " << f << std::endl;
        }
    }

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