Worried School HDU - 6008

本文介绍了一个竞赛晋级策略的实现方法,通过输入特定参数,程序能够判断参赛队伍是否能晋级,并在部分情况下输出关键的晋级门槛值。使用了C++语言进行实现,包括数据结构如集合的运用以及条件判断逻辑。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这个题就是前五个是中国赛区,最后一个是外国赛区,这里给你一个担心的的国家,中国赛区的取数是按照先取前五个赛区的第一再去第二第三这样,不能有重复的,我们要帮worried school看看它能不能进WF,如果对于任意的(x,y)都能使得worried school进WF,就输出“ADVANCED!”。而如果对于一些(x,y)能使得worried school进WF,另一些(x,y)不能,就输出最小的y,这个时候(x,y)恰好使得worried school不能进WF。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <math.h>
#include <stack>
#include <utility>
#include <string>
#include <sstream>
#include <cstdlib>
#include <set>
#define LL long long
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 10000 + 10;
int dir[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};
string a[10][100];
string b[100];
int g;
string sch;
int main()
{
    int t;
    scanf("%d",&t);
    int kase = 0;
    while(t--)
    {
        cin>>g>>sch;
        for(int i = 1; i <= 5; i++)
        {
            for(int j = 1; j <= 20; j++)
            {
                cin>>a[i][j];
            }
        }
        for(int i = 1; i <= 20; i++)
        {
            cin>>b[i];
        }
        set<string> q;
        int flag1;
        int flag2;
        int y = -INF;
        int x;
        for(x = 0; x <= g; x++)
        {
            q.clear();
            flag1 = 0;
            flag2 = 0;
            if(x > 0)
            {
                int num = 1;
                while(1)
                {
                    for(int k = 1; k <= 5; k++)
                    {
                        if(a[k][num] == sch)
                            flag1 = 1;
                        q.insert(a[k][num]);
                        if(q.size() >= x)
                        {
                            break;
                        }
                    }
                    num++;
                    if(q.size() >= x)
                        break;
                }
            }
            if(g > x)
            {
                for(int i = 1; i <= 20; i++)
                {
                    if(b[i] == sch)
                    {
                        flag2 = 1;
                    }
                    q.insert(b[i]);
                    if(q.size() >= g)
                        break;
                }
            }
            if(!flag1 && !flag2)
            {
                //cout<<y<<" "<<x<<endl;
                y = g - x;
            }
        }
        if(y != -INF)
            cout<<"Case #"<<++kase<<": "<<y<<endl;
        else
            cout<<"Case #"<<++kase<<": "<<"ADVANCED!"<<endl;
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值