zoukankan      html  css  js  c++  java
  • 【HDU 6008】Worried School(模拟)

    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
    

    Source


    2016 CCPC-Final

    参考代码

    #include <map>
    #include <queue>
    #include <cmath>
    #include <cstdio>
    #include <complex>
    #include <cstring>
    #include <cstdlib>
    #include <iostream>
    #include <algorithm>
    #define ll long long
    #define inf 1000000000
    #define PI acos(-1)
    #define REP(i,x,n) for(int i=x;i<=n;i++)
    #define DEP(i,n,x) for(int i=n;i>=x;i--)
    #define mem(a,x) memset(a,x,sizeof(a))
    using namespace std;
    ll read(){
        ll x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    void Out(ll a){
        if(a<0) putchar('-'),a=-a;
        if(a>=10) Out(a/10);
        putchar(a%10+'0');
    }
    const int N=50005;
    map<string,int>vis;
    string a[6][205],b[25];
    int main(){
        int T=read();
        string c,tmp;
        REP(i,1,T){
           int G=read();
           cin>>c;
           REP(i,1,5) REP(j,1,20) cin>>a[i][j];
           REP(i,1,20) cin>>b[i];
           int ans=inf;
           G=min(G,120);
           REP(x,0,G){
              vis.clear();
              int col=1,cnt=x;
              REP(i,1,100){
                 REP(j,1,5){
                     if(cnt==0) break;
                     if(vis[a[j][col]]) continue;
                     vis[a[j][col]]=1;
                     cnt--;
                 }
                 if(cnt==0) break;
                 col++;
              }
              cnt=G-x;
              REP(i,1,20){
                 if(cnt==0) break;
                 if(vis[b[i]]) continue;
                 vis[b[i]]=1;cnt--;
              }
              if(!vis[c]) ans=G-x;
           }
           printf("Case #%d: ",i);
           printf(ans==inf?"ADVANCED!
    ":"%d
    ",ans);
        }
        return 0;
    }
    
  • 相关阅读:
    WindowsXP/2000来帮您自动关机
    ASP程序加密/解密方法大揭密
    教你如何在Windows XP使用定时关机命令
    向左滚动 替代 Marquee
    [转]Subversion的权限控制
    Xplanner的安装
    推荐一个不错的浮动广告代码
    微软称20日验证Windows与Office 盗版将黑屏?!
    Internet Explorer 8 Beta 2十大看点
    [转]Subversion的权限控制
  • 原文地址:https://www.cnblogs.com/zsyacm666666/p/7218733.html
Copyright © 2011-2022 走看看