Live2d Test Env

ZOJ1171

错误代码先放这
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
map<char,string>Map;
string s;
char C[10000000];
int num[100];
void _solve(string v)
{
	string t=v;
	sort(t.begin(),t.end());
	num[t[0]-'0']++;
	Map[t[0]]=v;
	for(int i=1;i<t.length();i++)
	 if(t[i]!=t[i-1])
	  { 
		num[t[i]-'0']++;
	    Map[t[i]]=v;
	  }
}
int main()
{
	int T,n,TT;
    cin>>T;
	while(T--){
		memset(num,0,sizeof(num));
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		 {
			 cin>>s;
			 _solve(s);
		 }
		 char c=getchar();
		 int len=0;
		 c=getchar();
		 bool ok=true;
		 while(true){
			 if(c=='#') break;
			 if(islower(c)) toupper(c);
			 C[++len]=c;
			 if(isupper(c))
			  if(num[c-'0']!=1) 
			     ok=false;
			 c=getchar();
		 }
		 if(!ok) printf("AMBIGUITY\n");
		 else {
		  for(int i=1;i<=len;i++) 
		    if(isupper(C[i]))
		     cout<<Map[C[i]];
		    else putchar(C[i]);
		    cout<<endl;
		}
		if(T)cout<<endl;
	}
	return 0;
}

posted @ 2017-09-27 21:06  nimphy  阅读(127)  评论(0编辑  收藏  举报