結果

問題 No.408 五輪ピック
ユーザー eitahoeitaho
提出日時 2016-08-07 23:49:13
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,700 bytes
コンパイル時間 1,191 ms
コンパイル使用メモリ 87,440 KB
実行使用メモリ 251,392 KB
最終ジャッジ日時 2024-04-25 00:36:28
合計ジャッジ時間 7,272 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_05 AC 20 ms
8,192 KB
testcase_06 MLE -
testcase_07 MLE -
testcase_08 AC 27 ms
19,328 KB
testcase_09 AC 50 ms
52,992 KB
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 AC 22 ms
10,368 KB
testcase_14 AC 31 ms
40,192 KB
testcase_15 AC 17 ms
6,144 KB
testcase_16 AC 28 ms
15,616 KB
testcase_17 AC 48 ms
39,936 KB
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
testcase_21 AC 31 ms
43,008 KB
testcase_22 MLE -
testcase_23 MLE -
testcase_24 MLE -
testcase_25 AC 24 ms
6,656 KB
testcase_26 MLE -
testcase_27 AC 3,207 ms
6,656 KB
testcase_28 MLE -
testcase_29 MLE -
testcase_30 AC 2 ms
5,376 KB
testcase_31 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:56:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   56 |     scanf("%d %d", &N, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:60:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   60 |         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;
bool Adj[MaxN][MaxN];
Pii E[MaxM];

void solve() {
    rep(ea, M) {
        int a = E[ea].first, b = E[ea].second;
        if (!Adj[0][a] && !Adj[0][b]) continue;
        ll eb = lower_bound(E + ea + 1, E + M, Pii(a + 1, 0)) - E;
        for (; eb < M; eb++) {
            int c = E[eb].first, d = E[eb].second;
            if (Adj[0][a] && (Adj[b][c] && Adj[0][d] || Adj[b][d] && Adj[0][c]) ||
                Adj[0][b] && (Adj[a][c] && Adj[0][d] || Adj[a][d] && Adj[0][c])) {
                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] = Adj[b][a] = true;
        if (a > b) swap(a, b);
        if (a != 0) E[mi++] = Pii(a, b);
    }
    M = mi;
    sort(E, E + M);
    solve();
    return 0;
}
0