結果

問題 No.95 Alice and Graph
ユーザー omochana1omochana1
提出日時 2014-12-13 23:37:06
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,458 bytes
コンパイル時間 730 ms
コンパイル使用メモリ 90,464 KB
実行使用メモリ 16,628 KB
最終ジャッジ日時 2023-09-02 14:29:05
合計ジャッジ時間 13,227 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
#include <map>
#include <fstream>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <set>
#include <climits>
#define MAX_N 200010
#define PI 3.141592653589
#define ESP 1e-20
#define BS 10
#define MOD 1000000007 
#define ZERO 10001
#define YJSNPI 810
#define INF (1LL << 50)
#define ADD(a, b) a = (a + (ll)b) % MOD
#define MUL(a, b) a = (a * (ll)b) % MOD
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)

using namespace std;

typedef pair<int, int> pi;
typedef long long ll;

int N, M, K;
vector<int> E[MAX_N];
//bool used[MAX_N];

bool loop(int at, vector<int> goal, int life) {
	goal[at] = 0;
	if(goal == vector<int>(N, 0)) return true;
	if(life <= 0) return false;
	bool res = false;
	for(int i = 0; i < E[at].size(); i++) {
		res = max(res, loop(E[at][i], goal, life - 1));
	}
	return res;
}

int main() {
	cin >> N >> M >> K;
	for(int i = 0; i < M; i++) {
		int from, to;
		cin >> from >> to; from--; to--;
		E[from].push_back(to);
		E[to].push_back(from);
	}
	vector<int> ans(N, 0);
	for(int i = N - 1; i >= 0; i--) {
		ans[i] = 1;
		if(!loop(0, ans, K)) {
			ans[i] = 0;
		}
	}
	ll res = 0;
	for(int i = 0; i < N; i++) {
		if(ans[i]) res += (1LL << i) - 1;
	}
	cout << res << endl;
}
0