QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#129895 | #5250. Combination Locks | TadijaSebez | Compile Error | / | / | C++14 | 2.5kb | 2023-07-23 04:19:59 | 2023-07-23 04:20:03 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-07-23 04:20:03]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-07-23 04:19:59]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
char a[15],b[15],s[15];
const int N=1050;
const int inf=1e9+7;
bool ban[N],was[N];
int totalA,totalB;
int src,dest;
struct Edge{
int u,v,c,f;
};
vector<Edge> edges;
vector<int> E[N];
void AddEdge(int u,int v,int c){
E[u].pb(edges.size());
edges.pb(Edge{u,v,c,0});
E[v].pb(edges.size());
edges.pb(Edge{v,u,0,0});
}
int dist[N],ptr[N];
int DFS(int u,int flow){
if(u==dest)return flow;
if(dist[u]>=dist[dest])return 0;
int ans=0;
for(;ptr[u]<E[u].size();ptr[u]++){
int e=E[u][ptr[u]];
int cap=edges[e].c-edges[e].f;
int v=edges[e].v;
if(cap==0 || dist[v]!=dist[u]+1)continue;
int cut=DFS(v,min(flow,cap));
flow-=cut;
ans+=cut;
edges[e].f+=cut;
edges[e^1].f-=cut;
if(flow==0){
return ans;
}
}
return ans;
}
bool BFS(){
for(int i=0;i<=dest;i++){
dist[i]=-1;
ptr[i]=0;
}
queue<int> q;
q.push(src);
dist[src]=0;
while(q.size()){
int u=q.front();
q.pop();
for(auto e:E[u]){
int v=edges[e].v;
int cap=edges[e].c-edges[e].f;
if(cap!=0 && dist[v]==-1){
dist[v]=dist[u]+1;
q.push(v);
}
}
}
return dist[dest]!=-1;
}
int MaxFlow(){
int ans=0;
while(BFS()){
ans+=DFS(src,inf);
}
return ans;
}
void Build(int u,int n,int parity){
if(was[u])return;
int p=__builtin_popcount(u)&1;
if(p==parity){
totalA++;
AddEdge(src,u,1);
}else{
totalB++;
AddEdge(u,dest,1);
}
was[u]=true;
for(int i=0;i<n;i++){
int v=u^(1<<i);
if(ban[v])continue;
if(p==parity){
AddEdge(u,v,inf);
}
Build(v,n,parity);
}
}
int main(){
int t;
scanf("%i",&t);
while(t--){
int n,c;
scanf("%i %i",&n,&c);
scanf("%s",a);
scanf("%s",b);
int mask=0;
for(int i=0;i<n;i++){
if(a[i]==b[i]){
mask|=1<<i;
}
}
for(int j=0;j<c;j++){
scanf("%s",s);
int m=0;
for(int i=0;i<n;i++){
if(s[i]=='='){
m|=1<<i;
}
}
ban[m]=true;
}
src=(1<<n);
dest=(1<<n)+1;
totalA=0;
totalB=0;
Build(mask,n,__builtin_popcount(mask)&1);
int flow1=MaxFlow();
for(auto& edge:edges){
edge.f=0;
}
edges[0].c=0;
//int flow2=MaxFlow();
if(flow==totalA || (flow==totalA-1 && totalB>=totalA)){
//if(flow1>flow2){
printf("Alice\n");
}else{
printf("Bob\n");
}
for(int i=0;i<(1<<n);i++){
ban[i]=false;
was[i]=false;
}
for(int i=0;i<=dest;i++){
E[i].clear();
}
edges.clear();
}
return 0;
}
详细
answer.code: In function ‘int main()’: answer.code:137:20: error: ‘flow’ was not declared in this scope; did you mean ‘flow1’? 137 | if(flow==totalA || (flow==totalA-1 && totalB>=totalA)){ | ^~~~ | flow1 answer.code:102:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 102 | scanf("%i",&t); | ~~~~~^~~~~~~~~ answer.code:105:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 105 | scanf("%i %i",&n,&c); | ~~~~~^~~~~~~~~~~~~~~ answer.code:106:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 106 | scanf("%s",a); | ~~~~~^~~~~~~~ answer.code:107:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 107 | scanf("%s",b); | ~~~~~^~~~~~~~ answer.code:115:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 115 | scanf("%s",s); | ~~~~~^~~~~~~~