Problem J. Worried School(日期模拟 STL)

这题有个知识点上的 疏漏当进行过if(q[sx]==2)//当进行过这步操作后 就不能用!q.count(sx) 因为此时map中已经能发现sx了 只不过他的值还是0 所以使用map时尽量用数字代替#include #include #include #include #include #include #include #include #include #includ
摘要由CSDN通过智能技术生成



这题有个知识点上的 疏漏

当进行过

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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值