Algorithm


Problem Name: 2 AD-HOC - beecrowd | 2478

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/2478

Hit the Gift

 

By Jessica Dagostini, beecrowd BR Brazil

Timelimit: 1

In the Natalícia family, the realization of the Secret Santa on the Christmas eve is traditional. Every year the whole family gets together to exchange gifts. It's a time of great fun and relaxation.

This year the youngest member of the family, Jocelina, decided to make the moment even more fun: she proposed that all participants put on a list 3 suggestions for gifts. From this list, she thought in a program that inserted a name N and a gift P, the program returns if the person has hit or not the present for his secret friend.

But Jocelina does not know much of programming, and ended up needing help to make this program. You, being taken by the christmas spirit, accepted the challenge!

 

Input

 

The input consists in a several test cases and ends with EOF. The first line contain a number X (3 ≤ X ≤ 20) that represents the number of participants in the Secret Santa. The following X lines contain a name N and 3 options of desired gifts P. After this, the next lines will contain a name N and a gift P that represents the consults made.

 

Output

 

Your programm should return if the person hit or not the present, showing "Uhul! Seu amigo secreto vai adorar o/" (Yay! Your secret friend will love it!) if matched, and if not, "Tente Novamente!" (Try Again!);

 

 

 

Input Sample Output Sample

5

iara mochila estojo lapis

adelar sapato camisa carteira

jessica agenda bolsa brincos

jocelina xicara meias perfume

elaine sandalia sapatilha camiseta

jessica carteira

jessica agenda

iara sandalia

elaine mochila

iara mochila

adelar carteira

Tente Novamente!

Uhul! Seu amigo secreto vai adorar o/

Tente Novamente!

Tente Novamente!

Uhul! Seu amigo secreto vai adorar o/

Uhul! Seu amigo secreto vai adorar o/

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>
#include <map>
#include <string>
#define endl '\n'
using namespace std;
map < string, string> mapa1, mapa2, mapa3;
int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int n;
    cin >> n;
    while (n--) {
        string s1, s2, s3, s4;
        cin >> s1 >> s2 >> s3 >> s4;
        mapa1[s1] = s2;
        mapa2[s1] = s3;
        mapa3[s1] = s4;
    }
    string a, b;
    while (cin >> a >> b) {
        if (mapa1[a] == b || mapa2[a] == b || mapa3[a] == b) {
            cout << "Uhul! Seu amigo secreto vai adorar o/" << endl;
        } else {
            cout << "Tente Novamente!" << endl;
        }
    }
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
5
iara mochila estojo lapis
adelar sapato camisa carteira
jessica agenda bolsa brincos
jocelina xicara meias perfume
elaine sandalia sapatilha camiseta
jessica carteira
jessica agenda
iara sandalia
elaine mochila
iara mochila
adelar carteira

Output

x
+
cmd
Tente Novamente!
Uhul! Seu amigo secreto vai adorar o/
Tente Novamente!
Tente Novamente!
Uhul! Seu amigo secreto vai adorar o/
Uhul! Seu amigo secreto vai adorar o/
Advertisements

Demonstration


Previous
#2473 Beecrowd Online Judge Solution 2473 Loteria Solution in C, C++, Java, Js and Python
Next
#2479 Beecrowd Online Judge Solution 2479 Sorting Santa's List of Children Solution in C, C++, Java, Js and Python