E. Balloons Colors[ICPC Arab Collegiate Programming Contest 2013]

Posted iamcookieandyou

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了E. Balloons Colors[ICPC Arab Collegiate Programming Contest 2013]相关的知识,希望对你有一定的参考价值。

Assigning a balloon color to each problem is one of the tasks we need to do every year, and sometimes itis tricky.

We noticed that some contestants assume some colors for some problems according to the difficulty. Forexample, the easiest problem is the red one and the hardest problem is the black one. 

We do not want these assumptions to be true, so we decided to add constraints for the easiest and thehardest problems.

There are N problems, numbered from 1 to N , the easiest problem is problem number 1, and the hardestproblem is problem number N . Also there are N unique colors, for simplicity we will give each color aunique number from 1 to N .

We want to assign each color to exactly 1 problem, such that the easiest problem does not get the colorX and the hardest problem does not get the color Y . 

Given N , X , Y and an assignment of the colors, your task is to find if this assignment satisfies the aboveconditions or not.

Input

Your program will be tested on one or more test cases. The first line of the input will be a single integer T,the number of test cases (1 ≤ T ≤ 100). Followed by the test cases, the first line of each test case contains3 integers separated by a single space N X Y (3 ≤ N ≤ 100) and (1 ≤ X , Y ≤ N ) representing thenumber of problems, the color which the easiest problem should not get and the color which the hardestproblem should not get, respectively. Followed by a line which contains N integers separated by a singlespace (each integer from 1 to N should appear exactly once), the first integer is the color for the firstproblem (the easiest), the second integer is the color for the second problem and so on (the last integer isthe color for the hardest problem). 

Output

For each test case, print a single line which contains a single word, this word should be (without thequotes): 

- “BOTH”: If both the easiest and hardest problems got colors which they should not get.

- “EASY”: If only the easiest problem got a color which it should not get.

- “HARD”: If only the hardest problem got a color which it should not get.

- “OKAY”: If both the easiest and hardest problems got colors which they can get.

输出时每行末尾的多余空格,不影响答案正确性

样例输入

4
3 1 2
1 3 2
5 3 4
3 1 2 4 5
6 1 6
2 1 3 4 5 6
7 7 7
1 7 2 3 4 5 6

样例输出

BOTH
EASY
HARD
OKAY

#include <iostream>

using namespace std;

int t;

int main(){
    cin >> t;
    while (t -- ){
        int n, x, y;
        int a[110];
        scanf("%d%d%d", &n, &x, &y);
        
        for (int i = 1; i <= n; i ++ ) scanf("%d", &a[i]);
        
        if (a[1] == x && a[n] == y) puts("BOTH"); 
        if (a[1] == x && a[n] != y) puts("EASY"); 
        if (a[1] != x && a[n] == y) puts("HARD"); 
        if (a[1] != x && a[n] != y) puts("OKAY"); 
    }
    
    return 0;
}

  

以上是关于E. Balloons Colors[ICPC Arab Collegiate Programming Contest 2013]的主要内容,如果未能解决你的问题,请参考以下文章

2019ICPC西安邀请赛 E. Tree 树剖 + 线段树

2020-2021 ICPC Southeastern European Regional E. Divisible by 3(前缀和,优化暴力)

LA 8043. ACM-ICPC World Finals 2017 E. Need for Speed

ICPC 2019-2020 North-Western Russia Regional Contest E. Equidistant(分层)

ICPC 2019-2020 North-Western Russia Regional Contest E. Equidistant(分层)

ACM-ICPC 2018 焦作赛区网络预赛 E. Jiu Yuan Wants to Eat