結果
| 問題 |
No.408 五輪ピック
|
| コンテスト | |
| ユーザー |
eitaho
|
| 提出日時 | 2016-08-08 00:19:33 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3,209 ms / 5,000 ms |
| コード長 | 2,160 bytes |
| コンパイル時間 | 802 ms |
| コンパイル使用メモリ | 87,816 KB |
| 実行使用メモリ | 52,864 KB |
| 最終ジャッジ日時 | 2024-11-07 10:05:33 |
| 合計ジャッジ時間 | 6,655 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
コンパイルメッセージ
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);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#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;
}
eitaho