結果

問題 No.408 五輪ピック
ユーザー tubo28tubo28
提出日時 2016-08-05 23:47:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,310 bytes
コンパイル時間 1,402 ms
コンパイル使用メモリ 123,504 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-24 19:52:25
合計ジャッジ時間 3,434 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 2 ms
5,376 KB
testcase_05 AC 57 ms
5,376 KB
testcase_06 AC 19 ms
5,376 KB
testcase_07 AC 27 ms
5,376 KB
testcase_08 AC 21 ms
5,376 KB
testcase_09 AC 22 ms
5,376 KB
testcase_10 AC 18 ms
5,376 KB
testcase_11 AC 17 ms
5,376 KB
testcase_12 AC 30 ms
5,376 KB
testcase_13 AC 33 ms
5,376 KB
testcase_14 AC 8 ms
5,376 KB
testcase_15 AC 312 ms
5,376 KB
testcase_16 AC 30 ms
5,376 KB
testcase_17 AC 30 ms
5,376 KB
testcase_18 AC 32 ms
5,376 KB
testcase_19 AC 34 ms
5,376 KB
testcase_20 AC 11 ms
5,376 KB
testcase_21 AC 7 ms
5,376 KB
testcase_22 AC 17 ms
5,376 KB
testcase_23 AC 54 ms
6,016 KB
testcase_24 WA -
testcase_25 AC 29 ms
5,376 KB
testcase_26 AC 38 ms
5,504 KB
testcase_27 AC 29 ms
5,376 KB
testcase_28 AC 22 ms
5,376 KB
testcase_29 AC 22 ms
5,376 KB
testcase_30 WA -
testcase_31 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(cur,k) for (int cur = 0; cur < (int)(k); cur++)
#define all(cnt) begin(cnt), end(cnt)

const int INF = 1e9;

int n, m;
vector<vector<int>> g;
vector<int> dist;
vector<vector<int>> s;

int main() {
    srand(time(0));
    while (cin >> n >> m) {
        g.assign(n, {});
        for (int i = 0; i < m; i++) {
            int a, b;
            cin >> a >> b;
            --a; --b;
            g[a].emplace_back(b);
            g[b].emplace_back(a);
        }
        queue<int> q;
        q.push(0);
        dist.assign(n, INF);
        dist[0] = 0;
        while (q.size()) {
            int cur = q.front();
            q.pop();
            for (auto &dst : g[cur]) {
                if (dist[dst] == INF) {
                    q.push(dst);
                    dist[dst] = dist[cur] + 1;
                }
            }
        }
        s.assign(n, {});
        for (int i = 0; i < n; i++) {
            vector<int> &v = s[i];
            for (auto j : g[i]) {
                if (dist[j] == 1) {
                    v.push_back(j);
                }
            }
            random_shuffle(v.begin(), v.end());
            v.resize(min<int>(v.size(), 50));
        }

        bool ok = false;
        for (int i = 0; i < n; i++) {
            for (auto &j : g[i]) {
                auto &S = s[i];
                auto &T = s[j];
                for (auto &u : S) for (auto &v : T) {
                    if (u == j) continue;
                    if (v == i) continue;
                    if (u != v) ok = true;
                }
            }
        }
        cout << (ok ? "YES" : "NO") << endl;
    }
}
0