結果

問題 No.408 五輪ピック
ユーザー uenokuuenoku
提出日時 2017-01-15 02:15:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,479 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 80,892 KB
実行使用メモリ 9,928 KB
最終ジャッジ日時 2023-08-23 10:54:11
合計ジャッジ時間 2,666 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
8,296 KB
testcase_01 AC 5 ms
8,040 KB
testcase_02 AC 4 ms
8,068 KB
testcase_03 WA -
testcase_04 AC 5 ms
8,164 KB
testcase_05 AC 26 ms
9,064 KB
testcase_06 AC 19 ms
8,848 KB
testcase_07 AC 26 ms
9,104 KB
testcase_08 AC 22 ms
8,868 KB
testcase_09 AC 23 ms
8,984 KB
testcase_10 AC 19 ms
8,820 KB
testcase_11 AC 18 ms
8,724 KB
testcase_12 AC 30 ms
9,252 KB
testcase_13 AC 26 ms
9,152 KB
testcase_14 AC 10 ms
8,560 KB
testcase_15 AC 25 ms
9,248 KB
testcase_16 AC 28 ms
9,020 KB
testcase_17 AC 30 ms
9,276 KB
testcase_18 AC 32 ms
9,304 KB
testcase_19 AC 35 ms
9,624 KB
testcase_20 AC 12 ms
8,668 KB
testcase_21 AC 9 ms
8,292 KB
testcase_22 AC 17 ms
8,780 KB
testcase_23 AC 38 ms
9,928 KB
testcase_24 WA -
testcase_25 AC 25 ms
9,740 KB
testcase_26 AC 35 ms
9,520 KB
testcase_27 AC 25 ms
9,432 KB
testcase_28 AC 20 ms
8,832 KB
testcase_29 AC 21 ms
8,980 KB
testcase_30 AC 5 ms
8,112 KB
testcase_31 AC 5 ms
8,168 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