QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#89262#5250. Combination LocksjeffqiWA 2ms3616kbC++142.3kb2023-03-19 14:09:342023-03-19 14:09:36

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-19 14:09:36]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3616kb
  • [2023-03-19 14:09:34]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i <= (b); ++i)
#define drep(i,a,b) for (int i = (a); i >= (b); --i)
#define grep(i,u) for (int i = head[u],v = e[i].v; i; v = e[i = e[i].nxt].v)
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
LL read() {
	LL  x = 0,y = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') y = -y; ch = getchar();}
	while (isdigit(ch)) {x = x*10+ch-'0'; ch = getchar();} return x*y;
}
namespace qiqi {
	const int N = 10,M = 5e5,INF = 0x3f3f3f3f;
	int n,Q,m,s,t,sp,ecnt,head[M],vis[M],c[M],dep[M],cur[M];
	char s0[N],s1[N]; struct Edge {int v,f,nxt;} e[N*M];
	void add(int u,int v,int f) {e[++ecnt] = (Edge){v,f,head[u]}; head[u] = ecnt;}
	void fadd(int u,int v,int f) {add(u,v,f); add(v,u,0);}
	bool bfs(int s,int t) {
		rep(i,0,t) {cur[i] = head[i]; dep[i] = 0;}
		queue<int> q; dep[s] = 1; q.push(s);
		while (!q.empty()) {
			int u = q.front(); q.pop();
			grep(i,u) if (!dep[v] && e[i].f) {
				dep[v] = dep[u]+1; q.push(v);
			}
		}
		return dep[t] != 0;
	}
	int dfs(int u,int t,int f) {
		if (!f || u == t) return f; int res = 0;
		for (int &i = cur[u],v = e[i].v; i; v = e[i = e[i].nxt].v) {
			int k; if (dep[v] == dep[u]+1 && (k = dfs(v,t,min(f,e[i].f)))) {
				f -= k; res += k; e[i].f -= k; e[i^1].f += k; if (!f) break;
			}
		}
		return res;
	}
	int Dinic(int s,int t) {int res = 0; while (bfs(s,t)) res += dfs(s,t,INF); return res;}
	void main() {
		n = read(); Q = read();
		m = (1<<n)-1; sp = 0; ecnt = 1;
		rep(i,0,m) {
			head[i] = vis[i] = 0;
			c[i] = c[i>>1]^(i&1);
		}
		scanf("%s%s",s0,s1); rep(i,0,n-1) {
			sp |= (s0[i] == s1[i]) << i;
		}
		while (Q--) {
			int x = 0; scanf("%s",s0);
			rep(i,0,n-1) x |= s0[i] == '=';
			vis[x] = 1;
		}
		s = m+1; t = s+1;
		rep(i,s,t) head[i] = 0;
		rep(i,0,m) if (!vis[i]) {
			if (c[i] == c[sp]) {
				if (i != sp) fadd(s,i,1);
				rep(j,0,n-1) {
					int x = i^(1<<j);
					if (!vis[x]) fadd(i,x,1);
				}
			}
			else {
				fadd(i,t,1);
			}
		}
		Dinic(s,t); fadd(s,sp,1);
		puts(Dinic(s,t) ? "Bob" : "Alice");
	}
}
int main() {
	int T = read(); while (T--) qiqi::main(); return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3616kb

input:

2
1 0
0
0
1 1
0
0
.

output:

Bob
Alice

result:

wrong answer 1st lines differ - expected: 'Alice', found: 'Bob'