HDU6008-Worried School

本文介绍了一种世界总决赛(WF)名额分配的方法,分为两个阶段:第一阶段在中国五个区域赛中按特定规则分配X个名额;第二阶段剩余Y个名额分配给EC-Final的学校。文章探讨了如何确保某所学校无论X和Y取何值都能晋级WF,或者找出使该校无法晋级的最小Y值。

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

Worried School

                                                                        Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
                                                                                                  Total Submission(s): 182    Accepted Submission(s): 54


Problem Description
You may already know that how the World Finals slots are distributed in EC sub-region. But you still need to keep reading the problem in case some rules are different.
There are totally G slots for EC sub-region. X slots will be distributed among five China regional sites and Y slots will be distributed to the EC-Final. Of course X and Y are non-negative integers and X + Y = G.
Here is how the X slots be distributed:
      1. Slots are assigned to the Asia Regional sites from the first place, the second place, · · · , last place.
      2. For schools having the same place across the sites, the slots will be given in the order of the number of “effective 
         teams” in the sites.
      3. No school could be assigned a slot 2 times, which means the schools will be skipped if they already got a slot.

After X slots are distributed, the EC-Final ranklist from highest rank will be assigned Y slots for those schools that haven’t got a slot yet.
Now here comes a sad story, as X and Y are not announced until the end of the last regional contest of that year, even later!!!
Teachers from a school are worried about the whether they can advance to WF whatever the X and Y is. Let’s help them find out the results before the announcement of X and Y .
 

Input
The first line of the input gives the number of test cases, T. T test cases follow.
Each test case starts with a line consisting of 1 integer and 1 string, G representing the sum of X and Y and S representing the name of the worried school.
Next 5 lines each consists of 20 string representing the names of top 20 schools in each site. The sites are given in the order of the number of “effective teams” which means the first site has the largest number of “effective teams” and the last site has the smallest numebr of “effective teams”.
The last line consists of 20 strings representing the names of top 20 schools in EC-Final site. No school can appear more than once in each ranklist
 

Output
For each test case, output one line containing “Case #x: y”, where x is the test case number (starting from 1) and y is “ADVANCED!” if every non-negative value X, Y will advance the school. Otherwise, output the smallest value of Y that makes the school sad.
 1 ≤ T ≤ 200.
 School names only consist of upper case characters ‘A’ - ‘Z’ and the length is at most 5.
 1 ≤ G ≤ 20.
 

Sample Input
  
1 10 IJU UIV GEV LJTV UKV QLV TZTV AKOV TKUV GAV DVIL TDBV ILVTU AKV VTUD IJU IEV HVDBT YKUV ATUV TDOV TKUV UIV GEV AKV AKOV GAV DOV TZTV AVDD IEV LJTV CVQU HVDBT AKVU XIV TDVU OVEU OVBB KMV OFV QLV OCV TDVU COV EMVU TEV XIV VFTUD OVBB OFV DVHC ISCTU VTUD OVEU DTV HEVU TEOV TDV TDBV CKVU CVBB IJU QLV LDDLQ TZTV GEV GAV KMV OFV AVGF TXVTU VFTUD IEV OVEU OKV DVIL TEV XIV TDVU TKUV UIV DVIL VFTUD GEV ATUV AKV TZTV QLV TIV OVEU TKUV UKV IEV OKV CVQU COV OFOV CVBB TDVU IOV UIV TKUV CVBB AKV TZTV VFTUD UKV GEV QLV OVEU OVQU AKOV TDBV ATUV LDDLQ AKVU GAV SVD TDVU UPOHK
 

Sample Output
  
Case #1: 4
Hint
For the first test case, the optimal solution is X = 6 and Y = 4, at this time the advanced schools were [UIV, TKUV, QLV, CVBB, GEV, OCV, AKV, TZTV, VFTUD, UKV].
 

Source
 

Recommend
jiangzijing2015
 

题意:现在WF分配总共g个名额分为两块(x+y=g):

首先,分配x个名额给五个中国区域站。这五个中国区域站每个站都有20个学校,输入时这20个学校已经按照分数从大到小排好序。分配这x个名额的顺序:一号区域站第一名 -> 二号区域站第一名 -> 三号区域站第一名 -> 四号区域站第一名 -> 五号区域站第一名 -> 一号区域站第二名 -> 二号区域站第二名 -> …………但是如果有重复就跳过这个学校,因为一个学校最多只能占一个名额。然后,分配完x个名额后,剩下的y个名额分配给EC-Final中的20个学校,这20个学校输入时也按排名从高到低的顺序,这20个学校去除已经获得名额的学校后的第一名到第y名获得这y个名额。

现在帮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 <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>

using namespace std;

#define LL long long
const int INF=0x3f3f3f3f;

map<string,int>mp;
string s[10][25],s1;
int n;

int main()
{
    int t,cas=0;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        cin>>s1;
        for(int i=1; i<=6; i++)
            for(int j=1; j<=20; j++)
                cin>>s[i][j];
        mp.clear();
        int x=0,flag=0;
        for(int i=1; i<=20; i++)
        {
            for(int j=1; j<=5; j++)
            {
                if(s[j][i]==s1)
                {
                    flag=1;
                    break;
                }
                if(mp[s[j][i]]) continue;
                x++,mp[s[j][i]]=1;
            }
            if(flag) break;
        }
        int y=n-x,ans=max(y,0);
        flag=0;
        for(int i=1; i<=20; i++)
        {
            if(y<=0) break;
            if(s[6][i]==s1)
            {
                flag=1;
                break;
            }
            if(mp[s[6][i]]) continue;
            y--,mp[s[6][i]]=1;

        }
        printf("Case #%d: ",++cas);
        if(flag) printf("ADVANCED!\n");
        else printf("%d\n",ans);
    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值