Worried School

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

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].

 

题目是难读懂了点,但是本身并不是很难做,可以说直接进行模拟就行了。

说一下题目大意吧:

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

输入:
每个test的第一行是总名额数g和要查询是否能进WF的那个学校——worried school;
接下来的1到5行分别是一到五号区域站的20个学校。
在接下来的一行是EC-Final的20个学校。

现在,我们要帮worried school看看它能不能进WF,如果对于任意的(x,y)都能使得worried school进WF,就输出“ADVANCED!”。
而如果对于一些(x,y)能使得worried school进WF,另一些(x,y)不能,就输出最小的y,这个时候(x,y)恰好使得worried school不能进WF。

 #include<cstdio>
#include<cmath>
#include<set>
#include<iostream>
using namespace std;
int g;
string site[][],EC_site[],worried_school;
int main()
{
int t;
scanf("%d",&t);
for(int kase=;kase<=t;kase++)
{
cin>>g>>worried_school;
for(int i=;i<=;i++)
{
for(int j=;j<=;j++) cin>>site[i][j];
}
for(int j=;j<=;j++) cin>>EC_site[j]; int i,j,x,y=-;
set<string> adv_school;
for(int x=;x<=g;x++)
{
adv_school.clear();
bool can_adv_in_x=,can_adv_in_y=;
if(x>)//给5个site分配名额
{
for(int r=;r<=;r++)
{
i=r%; if(i==) i+=;
j=(int)ceil(r/5.0);
if(site[i][j]==worried_school) can_adv_in_x=;//目标学校可以进WF
adv_school.insert(site[i][j]);
if(adv_school.size()>=x) break;
}
}
if(g-x>)//给EC-Final分配名额
{
for(int j=;j<=;j++)
{
if(EC_site[j]==worried_school) can_adv_in_y=;
adv_school.insert(EC_site[j]);
if(adv_school.size()>=g) break;
}
}
if(!can_adv_in_x && !can_adv_in_y) y=g-x;
}
printf("Case #%d: ",kase);
if(y==-) printf("ADVANCED!\n");
else printf("%d\n",y);
}
}

HDU 6008 - Worried School的更多相关文章

  1. 【HDU 6008】Worried School(模拟)

    Problem Description You may already know that how the World Finals slots are distributed in EC sub-r ...

  2. CCPC 2016-2017, Finals

    A. HDU 5999 The Third Cup is Free 简单模拟. B. HDU 6000 Wash n 件衣服, m 个洗衣机,k 个烘干机.每个洗衣机和烘干机需要不同的时间.问 n 件 ...

  3. HDU 1160 DP最长子序列

    G - FatMouse's Speed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64 ...

  4. HDU 1160 FatMouse's Speed(要记录路径的二维LIS)

    FatMouse's Speed Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  5. hdu 4666:Hyperspace(最远曼哈顿距离 + STL使用)

    Hyperspace Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Tota ...

  6. 怒刷DP之 HDU 1160

    FatMouse's Speed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Su ...

  7. HDU 1160 FatMouse's Speed (DP)

    FatMouse's Speed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Su ...

  8. HDU 5542 - The Battle of Chibi - [离散化+树状数组优化DP]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5542 Problem DescriptionCao Cao made up a big army an ...

  9. FatMouse's Speed (hdu 1160)

          #include <iostream> #include <cstdio> #include <cstring> #include <algori ...

随机推荐

  1. Android测试跑单个包脚本文件

    脚本: adb shell monkey -p 应用包名 --throttle 随机事件间隔 -v -v -v -s 1 --ignore-security-exceptions --kill-pro ...

  2. Ulua_toLua_基本案例(六)_LuaCoroutine2

    Ulua_toLua_基本案例(六)_LuaCoroutine2 using UnityEngine; using System.Collections; using LuaInterface; pu ...

  3. GoF--服务定位器模式

    服务定位器模式(Service Locator Pattern)用在我们想使用 JNDI 查询定位各种服务的时候.考虑到为某个服务查找 JNDI 的代价很高,服务定位器模式充分利用了缓存技术.在首次请 ...

  4. error C4996: Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct

    使用VS13 跟  google protocbuf时出现了这个问题:真蛋疼,用别人的东西你就说不安全,用你自己的东西时你怎么不说不安全来着! 解决方案 在protoc   生成的头文件中加上 #pr ...

  5. hive操作

    1.创建hive分区表: create table invites (id int, name string) partitioned by (ds string) row format delimi ...

  6. Ansible的快速入门

    Ansible 是一个简单的自动化引擎,可完成配置管理,应用部署,服务编排等各种IT需求. Ansible使用python语言开发实现的开源软件,依赖于Jinjia2,paramiko和PyYAML这 ...

  7. no matching function for call to ‘std::basic_string<char>::assign(std::string&, int)

    使用string中的assign赋值函数报错,代码为: text0.assign(line,i+); 其中text0与line都为string类型 最后发现assign函数的原型为 string &a ...

  8. PHP多种序列化/反序列化的方法

    序列化是将变量转换为可保存或传输的字符串的过程:反序列化就是在适当的时候把这个字符串再转化成原来的变量使用.这两个过程结合起来,可以轻松地存储和传输数据,使程序更具维护性. 1. serialize和 ...

  9. 架设FTP Server-Windows Server 2012

    架设FTP Server-Windows Server 2012 https://jingyan.baidu.com/article/03b2f78c75b9b65ea237ae84.html   在 ...

  10. vue经验 - 实战疑点总结

    1.注册全局组件(是一个单vue页面组成的一个组件,而不是现拼的template结构) 结构: 代码:main.js import UserList from './components/UserLi ...