Gym 101086 M ACPC Headquarters : AASTMT (Stairway to Heaven)

本文介绍了一种解决ACPC竞赛中志愿者赛程冲突的方法,通过编写程序来检测志愿者是否被分配到同一时间段的不同比赛中,确保赛程安排合理。

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

M ACPC Headquarters : AASTMT (Stairway to Heaven)

As most of you know, the Arab Academy for Science and Technology and Maritime Transport in Alexandria, Egypt, hosts the ACPC Headquarters in the Regional Informatics Center (RIC), and it has been supporting our region with all kinds of resources it can provide, whether it was hosting nationals, regionals, or providing support for national contests around the Arab Region by sending its employees and students to participate in preparing contest systems, coaching, problem setting, and whatever these nationals ask for. However, ACPC’s volunteers’ schedules can get very busy, therefore, some conflicts might occur between the nationals they are assigned to help with. As to resolve these conflicts, Noura suggested that the SCPC2015 students can come up with a program that detects the conflicts in the contests’ schedule, and that is, detect for each volunteer whether they have been assigned to multiple contests running at the same time.

Given the requirements for each contest (contest name, start date, end date, number of required volunteers, volunteers’ names), print a list of volunteers’ names that have conflicts in their schedules, sorted in alphabetical order.

Input

The first line of input contains an integer T (1 ≤ T ≤ 330), the number of test cases.

Each test case will contain only one string S of length 7. Each letter of the string represents the difficulty level of a problem (from A to E), 'A' is the easiest and 'E' is the hardest.

Output

For each test case print "YES" if she can prepare a contest using the current problems, otherwise print "NO".

Example

Input

3
EBEABDA
CEDEACA
BDAAEAA

Output

YES
NO
YES

Note

Warning: large Input/Output data, be careful with certain languages.

Solution

Every person every day only one job, else is illegal;
Pay attention to the details. There’re 3 TLE results before this 293ms-AC solotion, just because of ignoring somebody already passed.

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
set<string> ss;
map<string,int> d;
int T,sum,n,m,s,e,v,tot;
string name;
bool sheet[10001][366];
int main() {
//    freopen("03.in","r",stdin);
//    freopen("03.out","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin>>T;
    while (T--) {
        d.clear();
        ss.clear();
        memset(sheet,0,sizeof(sheet));
        tot=0;
        cin>>n;
        while (n--) {
            cin>>name;
            cin>>s>>e>>v;
            while (v--) {
                cin>>name;
                if (!d[name]) d[name]=++tot;
                int p=d[name];
                if (sheet[p][0]) continue;
                for (int i=s; i<=e; ++i)
                    if (sheet[p][i]) {
                        sheet[p][0]=true;
                        ss.insert(name);
                        break;
                    } else sheet[p][i]=true;
            }
        }
        cout<<ss.size()<<endl;
        set<string>::iterator p;
        for (p=ss.begin(); p!=ss.end(); p++) cout<<(*p)<<endl;
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值