結果

問題 No.408 五輪ピック
ユーザー eitahoeitaho
提出日時 2016-08-07 23:39:12
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,733 bytes
コンパイル時間 991 ms
コンパイル使用メモリ 90,364 KB
実行使用メモリ 250,844 KB
最終ジャッジ日時 2024-04-25 00:35:31
合計ジャッジ時間 7,958 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 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,284 KB
testcase_06 MLE -
testcase_07 MLE -
testcase_08 AC 28 ms
19,456 KB
testcase_09 AC 51 ms
53,120 KB
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 AC 24 ms
10,360 KB
testcase_14 AC 30 ms
40,192 KB
testcase_15 AC 18 ms
6,144 KB
testcase_16 AC 31 ms
15,584 KB
testcase_17 AC 49 ms
39,728 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 23 ms
6,560 KB
testcase_26 MLE -
testcase_27 AC 2,825 ms
6,496 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:57:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   57 |     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];
vector<Pii> E;

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

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    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.push_back(Pii(a, b));
    }
    sort(E.begin(), E.end());
    solve();
    return 0;
}
0