Submission #70039199


Source Code Expand

/* Code By WCM */
/*
Date:
大致思路:
复杂度:
期望得分:
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <vector>
#include <queue>

using namespace std;

inline int read();
void write(int);
void writeln(int);

const int N = 2e5 + 5;
int T, n, m, K, f[N][21][2];
string s;
vector <int> G[N];

int dfs(int u, int k, int fl) {
	if(k == 0) return (s[u - 1] != 'A');
	if(f[u][k][fl] != -1) return f[u][k][fl];
	int res;
	if(fl == 0) {
		res = 1;
		for(int v : G[u]) {
			int nxt = dfs(v, k - 1, 1);
			if(nxt == 0) { res = 0; break; }
		}
	}
	else {
		res = 0;
		for(int v : G[u]) {
			int nxt = dfs(v, k - 1, 0);
			if(nxt == 1) { res = 1; break; }
		}
	}
	return f[u][k][fl] = res;
}

int main() {

//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> T;
	while(T--) {
		cin >> n >> m >> K >> s;
		for(int i = 1; i <= n; i++) G[i].clear();
		for(int i = 0, u, v; i < m; i++) {
			cin >> u >> v;
			G[u].push_back(v); 
		}
		for(int i = 1; i <= n; i++)
			for(int j = 0; j <= K * 2; j++)
				f[i][j][0] = f[i][j][1] = -1;
		int ans = dfs(1, K * 2, 0);
		cout << (ans == 0 ? "Alice\n" : "Bob\n");
	}
	
//	printf("\nThe time used: ");
//	printf("%.2lfs",(double)clock()/CLOCKS_PER_SEC);

	return 0;

}

inline int read() {
	int res = 0, f = 1;
	char ch = getchar();
	while( !(ch >= '0' && ch <= '9') ) {
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		res = (res << 1) + (res << 3) + (ch ^ 48);
		ch = getchar();
	}
	return res * f;
}

void write(int x) {
	static int sta[35];
	int top = 0;
	do {
		sta[top++] = x % 10;
		x /= 10;
	} while(x);
	while(top) putchar(sta[--top] ^ 48);
}

void writeln(int x) {
	write(x);
	putchar('\n');
}

Submission Info

Submission Time
Task D - The Simple Game
User WZwangchongming
Language C++ 20 (gcc 12.2)
Score 425
Code Size 1928 Byte
Status AC
Exec Time 55 ms
Memory 47268 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 1
AC × 24
Set Name Test Cases
Sample sample00.txt
All sample00.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt
Case Name Status Exec Time Memory
sample00.txt AC 2 ms 3380 KiB
testcase00.txt AC 18 ms 3584 KiB
testcase01.txt AC 19 ms 3456 KiB
testcase02.txt AC 17 ms 3556 KiB
testcase03.txt AC 19 ms 3512 KiB
testcase04.txt AC 16 ms 3616 KiB
testcase05.txt AC 55 ms 47268 KiB
testcase06.txt AC 53 ms 47260 KiB
testcase07.txt AC 54 ms 47244 KiB
testcase08.txt AC 17 ms 4520 KiB
testcase09.txt AC 16 ms 4364 KiB
testcase10.txt AC 18 ms 4348 KiB
testcase11.txt AC 28 ms 9548 KiB
testcase12.txt AC 22 ms 5164 KiB
testcase13.txt AC 20 ms 5484 KiB
testcase14.txt AC 31 ms 13076 KiB
testcase15.txt AC 34 ms 17948 KiB
testcase16.txt AC 22 ms 4964 KiB
testcase17.txt AC 15 ms 4764 KiB
testcase18.txt AC 43 ms 28484 KiB
testcase19.txt AC 50 ms 15040 KiB
testcase20.txt AC 20 ms 5404 KiB
testcase21.txt AC 20 ms 4972 KiB
testcase22.txt AC 37 ms 20524 KiB