DCP-189: Codeforces Username Back to All Problems

Medium Beginners Problems > Ad-hoc

Sometimes things are not as easy as you think. If you are a codeforces user, you can change your username once per year. Each of the username you are using must be available. Let me explain it. If the username what you want to set is currently in use by one of the user or has been used before, then it is an unavailable username. Even you can't switch to your old username. Now, you may think why codeforces doesn’t allow previously used usernames to reuse, they could just make the currently used username unavailable. It’s because if you search for a previously used username (currently not exists), they will give you the current profile of that user. Can you manage this system? Input: ------ Input starts with an integer **N (N <= 30000)**, number of operations. Each operation is one of these three type - - create username (create an user with current username) - change olduser newuser (change the uesrname of olduser with newuser) - search username ( give the current profile of matched username) It is guranteed that usernames only contain english alphabets and digits. Maximum length of username is 10. Output: ------- Print a line for every operation. For create and change operation, print ERROR or OK depending on whether the operation is valid or not. For searching, print ERROR if the username is never used. Otherwise, print the current username of the user. Sample Input ------------ 11 create feroz create ahmrf change feroz cnt search feroz create ahmrf create feroz search ahmrf change feroz froghramar create 1212 change 1212 feroz change ahmrf 1212 Sample Output ------------- OK OK OK cnt ERROR ERROR ahmrf ERROR OK ERROR ERROR

Problem Setter:

Feroz Ahmmed

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 2.00
C++ 2.00
C++14 2.00
C# 4.00
Go 4.00
Java 4.00
JavaScript 4.00
Objective-C 4.00
Perl 4.00
PHP 4.00
Python 4.00
Python3 4.00
Ruby 4.00
VB.Net 4.00

Problem Stats




# User Language Timing
01 feodorv Cpp14 0.03s
02 fsshakkhor Cpp14 0.10s
03 Robbinb1993 Cpp14 0.11s
04 Morass Cpp14 0.15s
05 sahedsohel Cpp14 0.15s
06 akazad_cse13_ruet Cpp14 0.16s
07 rajdipsaha Cpp14 0.22s
08 ssavi Cpp14 0.27s
09 Tanmoy_Datta Cpp14 0.28s
10 Dariwala Cpp14 0.29s
11 mir_lutfur_rahman Cpp14 0.30s
12 Gang_Of_Three_01 Cpp14 0.35s
13 CLown1331 Cpp14 0.36s
14 ksohan Cpp14 0.38s
15 NOxBODY Cpp14 0.38s
16 MI47 Cpp14 0.38s
17 RandyWaterhouse Python3 0.38s
18 nasif2587 Cpp14 0.39s
19 Zeronfinity Cpp14 0.40s
20 mdshs Cpp14 0.40s
21 MAHRahat Cpp14 0.40s
22 sayedgkm Cpp14 0.41s
23 Foysol_Ahmed Cpp14 0.41s
24 Tahmid Cpp14 0.41s
25 emrul Cpp14 0.42s
26 sangshaptac Cpp14 0.43s
27 Double_O Cpp14 0.43s
28 saiful130104 Cpp 0.43s
29 loop_breaker Cpp14 0.44s
30 rafiul41 Cpp14 0.44s
31 rafsan_rana Cpp14 0.44s
32 ovis96 Cpp14 0.44s
33 ToErr Cpp14 0.45s
34 zahid119 Cpp14 0.45s
35 Key_logger Cpp14 0.45s
36 froghramar Cpp14 0.46s
37 mamun4122 Cpp14 0.46s
38 PKP_007 Cpp14 0.47s
39 MazedRupok Cpp14 0.47s
40 abinash Cpp14 0.48s
41 imAnik Cpp14 0.50s
42 burhan103335 Cpp14 0.53s
43 tariqiitju Cpp14 0.53s
44 rash29 Cpp14 0.55s
45 Protap_Ghose Cpp14 0.56s
46 Masum_ice Cpp14 0.57s
47 darkprinx Cpp14 0.57s
48 The_mover Cpp14 0.58s
49 moshiur_cse15 Cpp14 0.58s
50 Knight_King Cpp14 0.59s

Your feedback is our precious!

Or call +88 02 9853138 for support