結果

問題 No.408 五輪ピック
ユーザー tubo28tubo28
提出日時 2016-08-05 23:41:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,277 bytes
コンパイル時間 1,927 ms
コンパイル使用メモリ 132,532 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-04-24 19:42:13
合計ジャッジ時間 3,901 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 148 ms
5,376 KB
testcase_06 AC 19 ms
5,376 KB
testcase_07 AC 27 ms
5,376 KB
testcase_08 AC 23 ms
5,376 KB
testcase_09 AC 21 ms
5,376 KB
testcase_10 AC 17 ms
5,376 KB
testcase_11 AC 17 ms
5,376 KB
testcase_12 AC 30 ms
5,376 KB
testcase_13 AC 96 ms
5,376 KB
testcase_14 AC 7 ms
5,376 KB
testcase_15 AC 132 ms
5,376 KB
testcase_16 AC 43 ms
5,376 KB
testcase_17 AC 31 ms
5,376 KB
testcase_18 AC 32 ms
5,376 KB
testcase_19 AC 33 ms
5,376 KB
testcase_20 AC 10 ms
5,376 KB
testcase_21 AC 7 ms
5,376 KB
testcase_22 AC 16 ms
5,376 KB
testcase_23 AC 97 ms
8,576 KB
testcase_24 WA -
testcase_25 AC 60 ms
5,376 KB
testcase_26 AC 37 ms
5,888 KB
testcase_27 AC 57 ms
5,376 KB
testcase_28 AC 43 ms
5,376 KB
testcase_29 AC 43 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<set<int>> s;

int main() {
    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++) {
            for (auto j : g[i]) {
                if (dist[j] == 1) {
                    s[i].insert(j);
                }
            }
            while (s[i].size() > 10) {
                auto it = s[i].begin();
                ++it; ++it; ++it;
                s[i].erase(it);
            }
        }

        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