結果

問題 No.408 五輪ピック
ユーザー tubo28tubo28
提出日時 2016-08-05 23:45:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,328 bytes
コンパイル時間 2,058 ms
コンパイル使用メモリ 135,096 KB
実行使用メモリ 15,872 KB
最終ジャッジ日時 2024-04-24 19:45:29
合計ジャッジ時間 13,588 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,376 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 286 ms
5,376 KB
testcase_06 AC 20 ms
5,376 KB
testcase_07 AC 28 ms
5,376 KB
testcase_08 AC 23 ms
5,376 KB
testcase_09 AC 23 ms
5,376 KB
testcase_10 AC 20 ms
5,376 KB
testcase_11 AC 18 ms
5,376 KB
testcase_12 AC 31 ms
5,376 KB
testcase_13 AC 104 ms
5,376 KB
testcase_14 AC 8 ms
5,376 KB
testcase_15 AC 4,101 ms
6,400 KB
testcase_16 AC 44 ms
5,376 KB
testcase_17 AC 33 ms
5,376 KB
testcase_18 AC 36 ms
5,376 KB
testcase_19 AC 36 ms
5,376 KB
testcase_20 AC 11 ms
5,376 KB
testcase_21 AC 7 ms
5,376 KB
testcase_22 AC 18 ms
5,504 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

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<set<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;
            for (auto j : g[i]) {
                if (dist[j] == 1) {
                    v.push_back(j);
                    s[i].insert(j);
                }
            }
            random_shuffle(v.begin(), v.end());
            v.resize(min<int>(v.size(), 50));
            s[i].insert(all(v));
        }

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