結果

問題 No.408 五輪ピック
ユーザー uenokuuenoku
提出日時 2017-01-15 02:20:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,490 bytes
コンパイル時間 2,867 ms
コンパイル使用メモリ 70,844 KB
実行使用メモリ 10,044 KB
最終ジャッジ日時 2023-08-23 10:55:04
合計ジャッジ時間 2,419 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,188 KB
testcase_01 AC 4 ms
8,036 KB
testcase_02 AC 5 ms
8,048 KB
testcase_03 WA -
testcase_04 AC 4 ms
8,176 KB
testcase_05 AC 25 ms
9,192 KB
testcase_06 AC 18 ms
8,864 KB
testcase_07 AC 26 ms
9,112 KB
testcase_08 AC 21 ms
8,872 KB
testcase_09 AC 22 ms
8,992 KB
testcase_10 AC 18 ms
8,904 KB
testcase_11 AC 18 ms
8,760 KB
testcase_12 AC 28 ms
9,280 KB
testcase_13 AC 25 ms
9,236 KB
testcase_14 AC 9 ms
8,432 KB
testcase_15 AC 25 ms
9,604 KB
testcase_16 AC 27 ms
9,116 KB
testcase_17 AC 30 ms
9,496 KB
testcase_18 AC 31 ms
9,272 KB
testcase_19 AC 32 ms
9,496 KB
testcase_20 AC 11 ms
8,636 KB
testcase_21 AC 8 ms
8,308 KB
testcase_22 AC 17 ms
8,820 KB
testcase_23 AC 38 ms
10,044 KB
testcase_24 WA -
testcase_25 AC 25 ms
9,820 KB
testcase_26 AC 34 ms
9,424 KB
testcase_27 AC 26 ms
9,468 KB
testcase_28 AC 20 ms
8,932 KB
testcase_29 AC 20 ms
8,804 KB
testcase_30 AC 4 ms
8,168 KB
testcase_31 AC 5 ms
8,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define mp make_pair
using namespace std;
typedef long long int lli;
lli MOD = 1000000007;
vector<int> e[100005];
vector<int> p[100005];
int f[100005];
int t[100005];

int main()
{
    int n, m;
    cin >> n >> m;
    int a, b;
    rep(i, m)
    {
        cin >> a >> b;
        a--, b--;
        e[a].push_back(b);
        e[b].push_back(a);
        f[i] = a, t[i] = b;
    }
    rep(i, e[0].size())
    {
        int in = e[0][i];
        rep(j, e[in].size())
        {
            if (e[in][j] != 0)
                p[e[in][j]].push_back(in);
        }
    }
    rep(i, m)
    {
        if (p[f[i]].size() == 0 || p[t[i]].size() == 0)
            continue;

        // if (p[f[i]].size() != p[t[i]].size()) {
        //     cout << "YES" << endl;
        //     return 0;
        // }
        bool flag[100005] = {};
        for (auto s : p[f[i]]) {
            if (s == f[i] || s == t[i])
                continue;
            flag[s] = true;
        }
        for (auto s : p[t[i]]) {
            if (s == f[i] || s == t[i])
                continue;
            if (!flag[s]) {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}
0