結果
| 問題 | No.408 五輪ピック |
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2016-09-15 19:41:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,208 bytes |
| 記録 | |
| コンパイル時間 | 1,289 ms |
| コンパイル使用メモリ | 100,192 KB |
| 実行使用メモリ | 509,344 KB |
| 最終ジャッジ日時 | 2024-11-17 06:12:22 |
| 合計ジャッジ時間 | 56,596 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 TLE * 7 MLE * 9 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;
#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl
vector<int> e[20000];
map<pair<set<int>,int>,bool> memo;
bool dfs(int v, set<int> s) {
if (memo.count({s,v})) return memo[{s,v}];
set<int> tmp = s;
tmp.insert(v);
bool ret = false;
for (auto x: e[v]) {
if (x == 0 && tmp.size() == 5) ret = true;
if (!tmp.count(x) && tmp.size() < 5) ret |= dfs(x,tmp);
}
return memo[{s,v}] = ret;
}
int main(void) {
int i, n, m;
scanf("%d%d",&n,&m);
REP (i,m) {
int a, b;
scanf("%d%d",&a,&b);
a--; b--;
e[a].push_back(b);
e[b].push_back(a);
}
if (dfs(0,{}))
puts("YES");
else
puts("NO");
return 0;
}
h_noson