这题有个知识点上的 疏漏
当进行过
if(q[sx]==2)//当进行过这步操作后 就不能用!q.count(sx) 因为此时map中已经能发现sx了 只不过他的值还是0 所以使用map时尽量用数字代替
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <climits>
#include <bits/stdc++.h>
using namespace std;
const int N = 30;
typedef long long LL;
map<string,int>q;
char str[N];
struct node
{
char ss[N];
}s[N][N];
int main()
{
int t, ncase=1;
scanf("%d", &t);
while(t--)
{
int n;
scanf("%d %s", &n, str);
string sh=str;
for(int i=1;i<=6;i++)
{
for(int j=1;j<=20;j++)
{
scanf("%s",s[i][j].ss);
}
}
int ans=-1;
for(int i=0;i<=n;i++)
{
int x=n-i,y=i;
q.clear();
q[sh]=2;
int cnt=0, flag=0;
for(int j=1;j<=20;j++)
{
for(int k=1;k<=5;k++)
{
string sx=s[k][j].ss;
if(cnt==x)
{
flag=1;
break;
}
if(q[sx]==2)
{
flag=2;
break;
}
if(q[sx]==0)
{
q[sx]=1;
cnt++;
}
if(cnt==x)
{
flag=1;
break;
}
}
if(flag)break;
}
if(flag==2) continue;
cnt=0, flag=0;
for(int j=1;j<=20;j++)
{
string sx=s[6][j].ss;
if(cnt==y)
{
flag=1;
break;
}
if(q[sx]==2)
{
flag=2;
break;
}
if(q[sx]==0)
{
q[s[6][j].ss]=1;
cnt++;
}
if(cnt==y)
{
flag=1;
break;
}
}
if(flag!=2)
{
ans=y;
break;
}
}
if(ans==-1) printf("Case #%d: ADVANCED!\n",ncase++);
else printf("Case #%d: %d\n",ncase++,ans);
}
return 0;
}