結果

問題 No.408 五輪ピック
ユーザー eitahoeitaho
提出日時 2016-08-08 00:23:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,691 ms / 5,000 ms
コード長 2,090 bytes
コンパイル時間 971 ms
コンパイル使用メモリ 87,648 KB
実行使用メモリ 52,736 KB
最終ジャッジ日時 2024-04-25 00:41:45
合計ジャッジ時間 6,983 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 14 ms
5,888 KB
testcase_06 AC 42 ms
50,816 KB
testcase_07 AC 38 ms
41,984 KB
testcase_08 AC 14 ms
9,856 KB
testcase_09 AC 22 ms
17,792 KB
testcase_10 AC 33 ms
34,944 KB
testcase_11 AC 30 ms
30,464 KB
testcase_12 AC 48 ms
36,992 KB
testcase_13 AC 16 ms
6,784 KB
testcase_14 AC 15 ms
17,792 KB
testcase_15 AC 14 ms
5,376 KB
testcase_16 AC 18 ms
8,832 KB
testcase_17 AC 23 ms
14,848 KB
testcase_18 AC 30 ms
23,424 KB
testcase_19 AC 40 ms
34,432 KB
testcase_20 AC 24 ms
32,000 KB
testcase_21 AC 14 ms
19,584 KB
testcase_22 AC 39 ms
51,200 KB
testcase_23 AC 49 ms
52,608 KB
testcase_24 AC 633 ms
52,480 KB
testcase_25 AC 22 ms
5,376 KB
testcase_26 AC 56 ms
52,736 KB
testcase_27 AC 3,691 ms
5,376 KB
testcase_28 AC 25 ms
27,904 KB
testcase_29 AC 24 ms
28,032 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:65:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   65 |     scanf("%d %d", &N, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:69:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   69 |         scanf("%d %d", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <climits>
#include <numeric>
#include <functional>
#include <time.h>
#include <bitset>
#include <emmintrin.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i <= (int)b; i++)
template<class T> void checkmin(T &a, T b) { if (b < a) a = b; }
template<class T> void checkmax(T &a, T b) { if (b > a) a = b; }

const int MaxN = 20000;
const int MaxM = 50000;
int N, M;
ll Adj[MaxN][(MaxN + 63) / 64];
Pii E[MaxM];

void solve() {
    rep(ea, M) {
        int a = E[ea].first, b = E[ea].second;
        bool adjA = Adj[0][a >> 6] >> a & 1;
        bool adjB = Adj[0][b >> 6] >> b & 1;
        if (!adjA && !adjB) continue;
        ll eb = lower_bound(E + ea + 1, E + M, Pii(a + 1, 0)) - E;
        for (; eb < M; eb++) if (E[eb].first != b && E[eb].second != b) {
            int c = E[eb].first, d = E[eb].second;
            if (Adj[0][c >> 6] >> c & 1) {
                if (adjA && Adj[b][d >> 6] >> d & 1 || adjB && Adj[a][d >> 6] >> d & 1) {
                    cout << "YES\n";
                    return;
                }
            }
            if (Adj[0][d >> 6] >> d & 1) {
                if (adjA && Adj[b][c >> 6] >> c & 1 || adjB && Adj[a][c >> 6] >> c & 1) {
                    cout << "YES\n";
                    return;
                }
            }
        }
    }
    cout << "NO\n";
}

int main() {
    scanf("%d %d", &N, &M);
    int mi = 0;
    rep(i, M) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        Adj[a][b >> 6] |= 1LL << b;
        Adj[b][a >> 6] |= 1LL << a;
        if (a > b) swap(a, b);
        if (a != 0) E[mi++] = Pii(a, b);
    }
    M = mi;
    sort(E, E + M);
    solve();
    return 0;
}
0