結果
問題 | No.408 五輪ピック |
ユーザー | eitaho |
提出日時 | 2016-08-08 00:19:33 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,160 bytes |
コンパイル時間 | 674 ms |
コンパイル使用メモリ | 89,000 KB |
実行使用メモリ | 52,656 KB |
最終ジャッジ日時 | 2023-08-07 06:33:19 |
合計ジャッジ時間 | 9,279 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 16 ms
7,456 KB |
testcase_06 | AC | 26 ms
52,436 KB |
testcase_07 | AC | 24 ms
42,320 KB |
testcase_08 | AC | 14 ms
11,488 KB |
testcase_09 | AC | 18 ms
17,880 KB |
testcase_10 | AC | 22 ms
35,972 KB |
testcase_11 | AC | 22 ms
31,868 KB |
testcase_12 | AC | 36 ms
38,216 KB |
testcase_13 | AC | 16 ms
7,600 KB |
testcase_14 | AC | 10 ms
19,500 KB |
testcase_15 | AC | 15 ms
5,028 KB |
testcase_16 | AC | 19 ms
9,552 KB |
testcase_17 | AC | 23 ms
15,640 KB |
testcase_18 | AC | 27 ms
23,940 KB |
testcase_19 | AC | 30 ms
36,244 KB |
testcase_20 | AC | 13 ms
33,832 KB |
testcase_21 | AC | 9 ms
21,620 KB |
testcase_22 | AC | 20 ms
52,328 KB |
testcase_23 | AC | 30 ms
52,648 KB |
testcase_24 | AC | 760 ms
52,488 KB |
testcase_25 | AC | 27 ms
5,600 KB |
testcase_26 | AC | 38 ms
52,656 KB |
testcase_27 | TLE | - |
testcase_28 | AC | 17 ms
29,888 KB |
testcase_29 | AC | 17 ms
29,760 KB |
testcase_30 | AC | 2 ms
4,380 KB |
testcase_31 | AC | 2 ms
4,376 KB |
ソースコード
#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 & 63) & 1; bool adjB = Adj[0][b >> 6] >> (b & 63) & 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 & 63) & 1) { if (adjA && Adj[b][d >> 6] >> (d & 63) & 1 || adjB && Adj[a][d >> 6] >> (d & 63) & 1) { cout << "YES\n"; return; } } if (Adj[0][d >> 6] >> (d & 63) & 1) { if (adjA && Adj[b][c >> 6] >> (c & 63) & 1 || adjB && Adj[a][c >> 6] >> (c & 63) & 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 & 63); Adj[b][a >> 6] |= 1LL << (a & 63); if (a > b) swap(a, b); if (a != 0) E[mi++] = Pii(a, b); } M = mi; sort(E, E + M); solve(); return 0; }