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 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
Output
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
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
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/