結果

問題 No.408 五輪ピック
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-08-07 04:17:54
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,529 bytes
コンパイル時間 705 ms
コンパイル使用メモリ 85,484 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-24 19:43:36
合計ジャッジ時間 9,729 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
10,496 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 24 ms
5,376 KB
testcase_06 AC 17 ms
5,376 KB
testcase_07 AC 25 ms
5,376 KB
testcase_08 AC 20 ms
5,376 KB
testcase_09 AC 21 ms
5,376 KB
testcase_10 AC 17 ms
5,376 KB
testcase_11 AC 16 ms
5,376 KB
testcase_12 AC 28 ms
5,376 KB
testcase_13 AC 25 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 30 ms
5,376 KB
testcase_18 AC 31 ms
5,376 KB
testcase_19 AC 32 ms
5,376 KB
testcase_20 AC 10 ms
5,376 KB
testcase_21 AC 6 ms
5,376 KB
testcase_22 AC 16 ms
5,376 KB
testcase_23 AC 33 ms
5,376 KB
testcase_24 AC 1,368 ms
5,376 KB
testcase_25 AC 150 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 <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
int n, m;
vector<int> g[20010];

int main(void){
    cin >> n >> m;
    rep(i, m){
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }


    //1 - u - vとなるような辺を見つける
    vector<pair<int, int> > d;
    for(int u : g[0]){
        for (int v : g[u]){
            //頂点に戻るようなものは入れない
            if(v != 0) d.push_back(make_pair(u, v));
        }
    }

    for (int i = 0; i < d.size() - 1; ++i){
        for (int j = i + 1; j < d.size(); ++j){
            if(d[i].first  != d[j].first && d[i].first  != d[j].second && 
               d[i].second != d[j].first && d[i].second != d[j].second){
                for (int tmp : g[d[i].second]){
                    if(tmp == d[j].second){
                        printf("YES\n");
                        return 0;
                    }
                }
            }
        }
    }
    printf("NO\n");
    return 0;
}
0