Major online platforms provide some free trial features to each account. When the trial period expires, users must pay to continue using them. Some people, to avoid paying, create many new accounts to access these free features. These individuals are affectionately referred to as "freebies" by netizens.
Sample Inputs/Outputs
Sample Input(s) | Sample Output(s) |
---|---|
輸入的第一行有一個正整數 N (1 <= N <= 2000),接下來下有 N 行註冊操作,每行包含兩個以空白隔開的字串 A 和 B,A 是註冊這個帳號時所使用的 Gmail,B 是本次註冊用戶輸入的用戶名,輸入字串包含英文字母、數字與符號。 | For each registration operation, if the email address A has not been used yet, please output "welcome, " followed by the username B; otherwise, output the username B followed by " account has been used", as shown in the sample output. |
4 [email protected] HiHi @gmail.com alex0301 @gmail.com HiHi NotGmail M_SQRT | welcome, HiHi welcome, alex0301 HiHi account has been used welcome, M_SQRT |
Thought Process
Use a Map to determine if each email address has been used. If Map[email] is 0, it means the email address has not been registered yet. If Map[email] is not 0, it means the email address has already been registered. Remember to increment Map[email] after each check.
Sample Code-ZeroJudge N369: Free Services
#include <iostream>
#include <map>
using namespace std;
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
int N;
cin >> N;
map<string, int>MAP;
for (int i = 0; i<N; i++)
{
string a, b;
cin >> a >> b;
if (MAP[a] == 0) cout << "welcome, " << b << "\n";
else cout << b << " account has been used\n";
MAP[a]++;
}
}
//ZeroJudge N369
//Dr. SeanXD