結果

問題 No.408 五輪ピック
ユーザー treeonetreeone
提出日時 2016-08-12 19:19:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 24 ms / 5,000 ms
コード長 1,169 bytes
コンパイル時間 1,208 ms
コンパイル使用メモリ 147,356 KB
実行使用メモリ 7,308 KB
最終ジャッジ日時 2023-08-07 08:32:24
合計ジャッジ時間 2,764 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,472 KB
testcase_03 AC 2 ms
4,428 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 13 ms
6,360 KB
testcase_06 AC 10 ms
5,484 KB
testcase_07 AC 14 ms
6,180 KB
testcase_08 AC 11 ms
5,780 KB
testcase_09 AC 12 ms
5,832 KB
testcase_10 AC 10 ms
5,476 KB
testcase_11 AC 10 ms
5,360 KB
testcase_12 AC 15 ms
6,192 KB
testcase_13 AC 13 ms
6,400 KB
testcase_14 AC 5 ms
4,812 KB
testcase_15 AC 13 ms
6,736 KB
testcase_16 AC 14 ms
6,608 KB
testcase_17 AC 15 ms
6,436 KB
testcase_18 AC 16 ms
6,660 KB
testcase_19 AC 18 ms
6,576 KB
testcase_20 AC 6 ms
4,900 KB
testcase_21 AC 4 ms
4,868 KB
testcase_22 AC 9 ms
5,424 KB
testcase_23 AC 24 ms
7,276 KB
testcase_24 AC 16 ms
6,344 KB
testcase_25 AC 15 ms
7,308 KB
testcase_26 AC 19 ms
6,716 KB
testcase_27 AC 18 ms
6,980 KB
testcase_28 AC 14 ms
5,896 KB
testcase_29 AC 24 ms
5,956 KB
testcase_30 AC 3 ms
4,408 KB
testcase_31 AC 2 ms
4,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
//#define FOR(i, a) for(auto& i : a)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

int n, m;
int a[50010], b[50010];
vector<int> e[20010], p[20010];

signed main(){
    cin >> n >> m;
    rep(i, 0, m){
        scanf("%d %d", &a[i], &b[i]);
        a[i]--;
        b[i]--;
        e[a[i]]. push_back(b[i]);
        e[b[i]]. push_back(a[i]);
    }
    //FOR(i, e[0]) FOR(j, e[i])
    rep(i, 0, e[0].size()){
        int t = e[0][i];
        rep(j, 0, e[t].size()){
            p[e[t][j]]. push_back(t);
        }
    }

    rep(i, 0, m){
        if(a[i] == 0 || b[i] == 0) continue;
        if(p[a[i]].size() > 3 && p[b[i]].size() > 3){
            cout << "YES" << endl;
            return 0;
        }
        rep(j, 0, p[a[i]].size()){
            rep(k, 0, p[b[i]].size()){
                if(p[a[i]][j] != p[b[i]][k] && p[a[i]][j] != b[i] && p[b[i]][k] != a[i]){
                    cout << "YES" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "NO" << endl;
}
0