結果

問題 No.408 五輪ピック
ユーザー h_nosonh_noson
提出日時 2016-09-15 19:41:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,208 bytes
コンパイル時間 1,056 ms
コンパイル使用メモリ 100,280 KB
実行使用メモリ 412,444 KB
最終ジャッジ日時 2024-04-28 13:52:37
合計ジャッジ時間 7,498 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,884 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 MLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0