QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#190960#5250. Combination Locksucup-team902#WA 0ms3600kbC++142.8kb2023-09-29 16:16:342023-09-29 16:16:35

Judging History

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

  • [2023-09-29 16:16:35]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2023-09-29 16:16:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pii pair<int,int>
#define ll long long
#define y1 shinkle
#define fi first
#define se second
#define bg begin
namespace IO{

cs int RLEN=1<<22|1;
#define gc getchar
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline ll readll(){
    char ch=gc();
    ll res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline char readchar(){
	char ch=gc();
	while(isspace(ch))ch=gc();
	return ch;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	s[top+1]='\0';return top;
}

}
using IO::read;
using IO::readll;
using IO::readchar;
using IO::readstring;
template<typename tp>inline void chemx(tp &a,tp b){(a<b)?(a=b):0;}
template<typename tp>inline void chemn(tp &a,tp b){(a>b)?(a=b):0;}


cs int N=1050;
char s[15],t[15];
int n,c;
int ban[N];
vector<int> e[N];
int pa[N],pb[N],vis[N];
int dfn,res;
bool dfs(int v){
    vis[v]=dfn;
    for(int u:e[v])if(!ban[u]){
        if(pb[u]==-1){
            pb[u]=v;
            pa[v]=u;
            return 1;
        }
    }
    for(int u:e[v])if(!ban[u]){
        if(vis[pb[u]]!=dfn&&dfs(pb[u])){
            pa[v]=u;
            pb[u]=v;
            return 1;
        }
    }
    return 0;
}
int calc(){
    res=0;dfn=0;
    memset(vis,0,sizeof(vis));
    memset(pa,-1,sizeof(pa));
    memset(pb,-1,sizeof(pb));
    while(1){
        dfn++;
        int cnt=0;
        for(int i=0;i<(1<<n);i++)if(__builtin_popcount(i)%2==0){
            if(pa[i]==-1&&dfs(i)){
                cnt++;
            }
        }
        if(cnt==0)break;
        res+=cnt;
    }
    return res;
}
void solve(){
    n=read(),c=read();
    readstring(s);
    readstring(t);
    int st=0;
    int lim=1<<n;
    for(int i=0;i<lim;i++){
        for(int j=0;j<n;j++)e[i].push_back(i^(1<<j));//,cout<<i<<" "<<(i^(1<<j))<<'\n';
    }
    for(int i=1;i<=n;i++){
        st<<=1;
        if(s[i]==t[i])st++;
    }
    //cout<<st<<'\n';
    for(int i=1;i<=c;i++){
        readstring(s);
        int sm=0;
        for(int j=1;j<=n;j++){
            sm<<=1;
            if(s[j]=='=')sm++;
        }
        ban[sm]=1;
    //    cout<<sm<<'\n';
    }
    int x=calc();
    ban[st]=1;
    int y=calc();
    //cout<<x<<" "<<y<<'\n';
    if(x==y)cout<<"Alice\n";
    else cout<<"Bob\n";
    memset(ban,0,sizeof(ban));
    for(int i=0;i<lim;i++)e[i].clear();
    memset(vis,0,sizeof(vis));
}

int main(){
    int T=read();
    while(T--)solve();
    return 0;;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3600kb

input:

2
1 0
0
0
1 1
0
0
.

output:

Bob
Bob

result:

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