???本地评测没问题,交上去却挂了
查看原帖
???本地评测没问题,交上去却挂了
767125
hxuwna楼主2024/12/26 19:57

评测 #1:

2 2 4
HELLO
GUILTY
HELLO: What is your name?
GUILTY: I am GUILTY.
GUILTY: Are you guilty?
HELLO: I am not guilty.

HELLO
#include<bits/stdc++.h>
using namespace std;
int const maxn=22,maxm=255,maxp=1e2+10;
int m,n,p,cnt,cntt,cnttt[maxp],v[maxp],who[maxn],vv[maxn],ans;
string strr[maxp][maxm],str,name[maxn];
map<string,int>id;
int zf[maxn],td,vd[8];
int check(int x){
	int sum=0;
	for(int i=0;i<m;i++){
		if(x&(1<<i)) sum++;
	}
//	cout<<1;
	if(sum!=n) return 0;
	td=0,memset(zf,0,sizeof(zf)),memset(vd,0,sizeof(vd));
	for(int i=1;i<=p;i++){
//		cout<<zf[1]<<" "<<zf[2]<<" "<<zf[3]<<"\n";
		if(v[i]) continue;
		if(id[strr[i][1]]==-1){
			if(id[strr[i][3]]==-4){
				if(x&(1<<(who[i]-1))){
					if(zf[who[i]]==0){
						zf[who[i]]=1;
					}else if(zf[who[i]]==-1){
						return 0;
					}
				}else{
					if(zf[who[i]]==0){
						zf[who[i]]=-1;
					}else if(zf[who[i]]==1){
						return 0;
					}
				}
			}else{
				if(x&(1<<(who[i]-1))){
					if(zf[who[i]]==0){
						zf[who[i]]=-1;
					}else if(zf[who[i]]==1){
						return 0;
					}
				}else{
					if(zf[who[i]]==0){
						zf[who[i]]=1;
					}else if(zf[who[i]]==-1){
						return 0;
					}
				}
			}
		}else if(id[strr[i][1]]>0){
			if(id[strr[i][3]]==-4){
				if(x&(1<<(who[i]-1))){
					if(zf[id[strr[i][1]]]==0){
						zf[id[strr[i][1]]]=1;
					}else if(zf[id[strr[i][1]]]==-1){
						return 0;
					}
				}else{
					if(zf[id[strr[i][1]]]==0){
						zf[id[strr[i][1]]]=-1;
					}else if(zf[id[strr[i][1]]]==1){
						return 0;
					}
				}
			}else{
				if(x&(1<<(who[i]-1))){
					if(zf[id[strr[i][1]]]==0){
						zf[id[strr[i][1]]]=-1;
					}else if(zf[id[strr[i][1]]]==1){
						return 0;
					}
				}else{
					if(zf[id[strr[i][1]]]==0){
						zf[id[strr[i][1]]]=1;
					}else if(zf[id[strr[i][1]]]==-1){
						return 0;
					}
				}
			}
		}else{
			if(x&(1<<(who[i]-1))){
				if(td==-id[strr[i][3]]-6){
					return 0;
				}else{
					vd[-id[strr[i][3]]-6]=1;
				}
			}else{
				if(td!=-id[strr[i][3]]-6&&td!=0){
					return 0;
				}else if(td==0){
					if(vd[-id[strr[i][3]]-6]) return 0;
					td=-id[strr[i][3]]-6;
				}
			}
		}
	}
	sum=0;
	int w;
	for(int i=1;i<=m;i++){
		if(zf[i]==1) sum++,w=i;
	}
	if(sum!=1) return 0;
	if(td==0&&vd[1]&&vd[2]&&vd[3]&&vd[4]&&vd[5]&&vd[6]&&vd[7]) return 0;
	return w;
}
int main(){
//  freopen("1.in","r",stdin);
//  freopen(".out","w",stdout);
//	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>m>>n>>p;
	for(int i=1;i<=m;i++){
		cin>>name[i];
		id[name[i]]=i;
	}
	id["I"]=-1,id["Today"]=-2,id["am"]=-3,id["not"]=-4,id["is"]=-5,id["guilty."]=-6,id["Monday."]=-7,id["Tuesday."]=-8,id["Wednesday."]=-9,id["Thursday."]=-10,id["Friday."]=-11,id["Saturday."]=-12,id["Sunday."]=-13;
	for(int i=1;i<=p;i++){
		int t=0;
		char gett;
		str="";
		while(1){
			gett=getchar();
			if(gett==':'){
				break;
			}
			str+=gett;
		}
		getchar();
		who[i]=id[str];
		str="";
		while(1){
			gett=getchar();
			if(gett==' '){
				break;
			}else if(gett=='\n'){
				t=1;
				break;
			}
			str+=gett;
		}
		strr[i][++cnttt[i]]=str;
		if(t==1){
			v[i]=1;
		}else if(id[str]==-1){
			cnt=0;
			str="";
			while(1){
				gett=getchar();
				if(gett==' '){
					break;
				}else if(gett=='\n'){
					t=1;
					break;
				}
				str+=gett;
			}
			strr[i][++cnttt[i]]=str;
			if(t){
				v[i]=1;
			}else if(id[str]==-3){
				cnt=0;
				str="";
				while(1){
					gett=getchar();
					if(gett==' '){
						break;
					}else if(gett=='\n'){
						t=1;
						break;
					}
					str+=gett;
				}
				strr[i][++cnttt[i]]=str;
//				cout<<i<<" "<<id[str]<<"\n";
				if(t&&id[str]!=-6){
					v[i]=1;
				}else if(id[str]==-4){
					cnt=0;
					str="";
					while(1){
						gett=getchar();
						if(gett==' '){
							break;
						}else if(gett=='\n'){
							t=1;
							break;
						}
						str+=gett;
					}
					strr[i][++cnttt[i]]=str;
					if(id[str]==-6){
						if(i==p) t=1;
						if(t==0){
							v[i]=1;
						}
					}else{
						v[i]=1;
					}
				}else if(id[str]==-6){
					if(i==p) t=1;
					if(t==0){
						v[i]=1;
					}
				}else{
					v[i]=1;
				}
			}else{
				v[i]=1;
			}
		}else if(id[str]>0){
			cnt=0;
			str="";
			while(1){
				gett=getchar();
				if(gett==' '){
					break;
				}else if(gett=='\n'){
					t=1;
					break;
				}
				str+=gett;
			}
			strr[i][++cnttt[i]]=str;
			if(t){
				v[i]=1;
			}else if(id[str]==-5){
				cnt=0;
				str="";
				while(1){
					gett=getchar();
					if(gett==' '){
						break;
					}else if(gett=='\n'){
						t=1;
						break;
					}
					str+=gett;
				}
				strr[i][++cnttt[i]]=str;
				if(t&&id[str]!=-6){
					v[i]=1;
				}else if(id[str]==-4){
					cnt=0;
					str="";
					while(1){
						gett=getchar();
						if(gett==' '){
							break;
						}else if(gett=='\n'){
							t=1;
							break;
						}
						str+=gett;
					}
					strr[i][++cnttt[i]]=str;
					if(id[str]==-6){
					if(i==p) t=1;
						if(t==0){
							v[i]=1;
						}
					}else{
						v[i]=1;
					}
				}else if(id[str]==-6){
					if(i==p) t=1;
					if(t==0){
						v[i]=1;
					}
				}else{
					v[i]=1;
				}
			}else{
				v[i]=1;
			}
		}else if(id[str]==-2){
			cnt=0;
			str="";
			while(1){
				gett=getchar();
				if(gett==' '){
					break;
				}else if(gett=='\n'){
					t=1;
					break;
				}
				str+=gett;
			}
			strr[i][++cnttt[i]]=str;
			if(t){
				v[i]=1;
			}else if(id[str]==-5){
				cnt=0;
				str="";
				while(1){
					gett=getchar();
					if(gett==' '){
						break;
					}else if(gett=='\n'){
						t=1;
						break;
					}
					str+=gett;
				}
				strr[i][++cnttt[i]]=str;
				if(id[str]<=-7&&id[str]>=-13){
					if(i==p) t=1;
					if(t==0){
						v[i]=1;
					}
				}
			}else{
				v[i]=1;
			}
		}else{
			v[i]=1;
		}
		if(t==0){
			while(1){
				gett=getchar();
				if(gett=='\n') break;
			}
		}
//		cout<<i<<" "<<v[i]<<"\n";
	}
	int w;
	for(int i=0;i<(1<<m);i++){
		int x=check(i);
//		cout<<i<<" "<<x<<"\n";
		if(x!=0){
			if(vv[x]==0){
				vv[x]=1;
				ans++;
				w=x;
			}
		}
//		cout<<"\n";
	}
//	check(1);
//	for(int i=1;i<=p;i++) cout<<v[i]<<" ";
	if(ans==0) cout<<"Impossible";
	else if(ans>1) cout<<"Cannot Determine";
	else cout<<name[w];
	return 0;
}

2024/12/26 19:57
加载中...