結果

問題 No.95 Alice and Graph
ユーザー omochana1omochana1
提出日時 2014-12-13 23:50:34
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,474 bytes
コンパイル時間 884 ms
コンパイル使用メモリ 89,000 KB
実行使用メモリ 8,300 KB
最終ジャッジ日時 2023-09-02 14:29:31
合計ジャッジ時間 1,720 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 5 ms
8,060 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 5 ms
8,048 KB
testcase_09 AC 5 ms
8,100 KB
testcase_10 AC 4 ms
8,240 KB
testcase_11 AC 5 ms
8,148 KB
testcase_12 AC 5 ms
8,220 KB
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

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, ll goal, int life) {
	if(goal & (1LL << at)) goal ^= (1LL << at);
	if(goal == 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));
		if(res) return true;
	}
	return res;
}

int main() {
	fstream file("in.txt");
	file >> N >> M >> K;
	for(int i = 0; i < M; i++) {
		int from, to;
		file >> from >> to; from--; to--;
		E[from].push_back(to);
		E[to].push_back(from);
	}
	ll ans = 0;
	for(int i = N - 1; i >= 0; i--) {
		ans |= (1LL << i);
		if(!loop(0, ans, K)) {
			ans ^= (1LL << i);
		}
	}
	ll res = 0;
	cout << ans - __builtin_popcountll(ans) << endl;
}
0