Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
WA7 | Aleksei Odintsov | 2002. Тестовое задание | 23 фев 2023 13:29 | 1 |
WA7 Aleksei Odintsov 23 фев 2023 13:29 What is in test7? Edited by author 23.02.2023 13:59 |
I hate the time limit | Savchuk Nickolay | 2002. Тестовое задание | 14 июл 2021 17:34 | 2 |
l1=[] l2=[] l3=[] for i in range(0,1000): l3.append(False) def funct(a): b=a.split() if b[0]=='register': if b[1] not in l1: l1.append(b[1]) l2.append(b[2]) print("success: new user added") else: print("fail: user already exists") elif b[0]=="login": if b[1] not in l1: print("fail: no such user") else: k=l1.index(b[1]) if l3[k]: print("fail: already logged in") else: if l2[k]==b[2]: l3[k]=True print("success: user logged in") else: print("fail: incorrect password") elif b[0]=="logout": k=l1.index(b[1]) if l3[k]: l3[k]=False print("success: user logged out") else: print("fail: already logged out") f=int(input()) for m in range(0,f): n=input() funct(n) f**king time limit!!! List is O(n) lookup, while dict is O(log n), so use that |
Hint | Yerdaulet | 2002. Тестовое задание | 3 янв 2021 20:40 | 1 |
Hint Yerdaulet 3 янв 2021 20:40 in some cases, there are more than 1 current user |
WA4 | Jormungand | 2002. Тестовое задание | 5 дек 2020 18:19 | 3 |
WA4 Jormungand 14 сен 2014 21:09 test 4 ??? help me please Re: WA4 Vikharev Vyacheslav 14 сен 2014 23:26 IT IS NOT PROBLEM!! PROBLEM IS THIRD TEST!!! BUT JUST IF YOU WRITE BY C# :) Re: WA4 Țigoan Matei 5 дек 2020 18:19 If you did it with binary search don't forget to sort the array every time you register a new user. |
WA 3 | FBI | 2002. Тестовое задание | 26 ноя 2020 15:42 | 14 |
WA 3 FBI 9 ноя 2013 16:21 test 3 ??? help me please Re: WA 3 Phillip Chelemer 9 ноя 2013 16:48 Re: WA 3 Muzaffardjan Karaev 9 ноя 2013 17:06 please can anyone tell me what is the test of 3. register user1 1 success: new user added register user2 2 success: new user added register user3 3 success: new user added logout user2 fail: already logged out login user1 3 fail: incorrect password login user2 2 success: user logged in logout user3 fail: already logged out note the last line Re: WA 3 Gleb_Kazantaev(NNSTU) 5 янв 2014 16:03 Try this: 4 register a 1 register a 2 register a 3 register a 4 Re: WA 3 Mescheryakov_Kirill 26 мар 2014 15:54 And that the last line is not so? Like everything correctly. It is easy. Just if else and use map, and define a new data structure, and there you go, all done. you may have problem with double login: register v 1 success: new user added login v 1 success: user logged in login v 1 fail: already logged in 2 register x y register x y Out success: new user added fail: user already exists Try this! input: 3 register a 1 login a 1 login a 2 output: success: new user added success: user logged in fail: incorrect password NOTE! Login with wrong pw should output "fail: incorrect password" instead of "fail: already logged in". Re: WA 3 Sanatbek_Matlatipov 1 сен 2015 11:56 Great. I didn't notice that. |
WA 7 | Kostuan1989 | 2002. Тестовое задание | 20 янв 2020 11:08 | 1 |
WA 7 Kostuan1989 20 янв 2020 11:08 Please help with wrong answer 7. Possible input? |
WA for test 5 | Md. Mostafizur Rahman | 2002. Тестовое задание | 26 ноя 2019 01:53 | 2 |
please can anyone tell me what is the test of 5. |
I solved it with Python | Mahilewets | 2002. Тестовое задание | 20 июн 2017 00:56 | 1 |
I tried to solve it with C++. It was long. It was PAINFUL! Finally, I didn't managed to solve it in C++. And then I just opened my Python IDE and solves it within 10 minutes. Just AC first attempt. The task is evil. |
WA7 | AtiKun | 2002. Тестовое задание | 27 ноя 2016 18:06 | 1 |
WA7 AtiKun 27 ноя 2016 18:06 ll n, k, op, a[11][11], ans; string s; vector < pair < string, string > > alr; vector < pair < string, string > > lg; vector < string > out; int main(){ cin >> n; for(ll i = 1; i <= n; i++){ cin >> s; k = 0; if(s == "register"){ string lo, pa; cin >> lo >> pa; for(ll i = 0; i < lg.size(); i++){ if(lo == lg[i].first){ cout << "fail: user already exists" << "\n"; k = 3; break; } } if(k != 3){ lg.pb(mp(lo, pa)); cout << "success: new user added" << "\n"; } } k = 0; if(s == "login"){ string acc, par; cin >> acc >> par; for(ll i = 0; i < alr.size(); i++){ if(acc == alr[i].first){ if(par == alr[i].second){ cout << "fail: already logged in"; k = 2; break; } } } for(ll i = 0; i < lg.size(); i++){ if(acc == lg[i].first && k != 2){ ans++; if(par == lg[i].second){ cout << "success: user logged in"; alr.pb(mp(acc, par)); out.pb(acc); k = 1; break; } } } if(!k && ans == 0) cout << "fail: no such user"; if(!k && ans > 0) cout << "fail: incorrect password"; cout << "\n"; } ans = 0; k = 0; if(s == "logout"){ string avt; ll o; cin >> avt; for(ll i = 0; i < out.size(); i++){ if(avt == out[i]){ out[i] = "````````21"; k = 4; break; } } op = 0; for(ll i = 0; i < lg.size(); i++){ if(avt == lg[i].first){ op = 1; break; } } if(k != 4 && op){ cout << "fail: already logged out"; } else if(op) cout << "success: user logged out"; if(!op) cout << "fail: no such user"; cout << "\n"; } op = 0; k = 0; } } what is wrong??? |
JAVA, plz help | fletcher6847 | 2002. Тестовое задание | 11 ноя 2016 13:00 | 2 |
import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Timus2002 { public static void main(String[] args) { Map<String, String> map = new HashMap<>(); Scanner sc = new Scanner(System.in); String[] s = new String[105]; ArrayList<String> logged = new ArrayList<>(); int n = Integer.parseInt(sc.nextLine()); for (int i = 0; i < n; i++) { s[i] = sc.nextLine(); } for (int i = 0; i < n; i++) { String[] mas = s[i].split(" "); if(mas[0].equals("register")){ if(map.containsKey(mas[1])){ System.out.println("fail: user already exists"); continue; } map.put(mas[1], mas[2]); System.out.println("success: new user added"); } String login = mas[1]; if(mas[0].equals("login")){ String pass = mas[2]; if(!map.containsKey(login)) { System.out.println("fail: no such user"); continue; } String value = map.get(login); if(!value.equals(pass)) System.out.println("fail: incorrect password"); if(value.equals(pass)) { if (!logged.contains(login)) { logged.add(login); System.out.println("success: user logged in"); } else System.out.println("fail: already logged in"); } } if(mas[0].equals("logout")) { if (!map.containsKey(login)) System.out.println("fail: no such user"); if (!logged.contains(login)) System.out.println("fail: already logged out"); else { System.out.println("success: user logged out"); logged.remove(login); } } } } } It works, but cant pass the test |
WA 3 | Alexander_Fedotov_TverSU | 2002. Тестовое задание | 2 авг 2016 23:44 | 3 |
WA 3 Alexander_Fedotov_TverSU 2 авг 2016 21:55 Help me please.. Why WA 3? I "Use this letter as a formal description of the algorithm and follow the described format of system messages" and still get Wrong Answer.. This test is correct? 7 login a 1 fail: no such user logout a fail: no such user register a 1 success: new user added login a 1 success: user logged in login a 1 fail: already logged in login a 2 fail: incorrect password register a 2 fail: user already exist Maybe you tell a counterexample or hint? Thanks. Edited by author 02.08.2016 21:56 Your last row is: fail: user already exist Correct one is: fail: user already exists Pay attention. Other than that, test seems ok to me. Re: WA 3 Alexander_Fedotov_TverSU 2 авг 2016 23:44 Oh, god... Thank you, Oleg! I got AC. |
Access Violation Test 4 | JohNY_green | 2002. Тестовое задание | 25 апр 2016 14:26 | 5 |
Can anyone tell me the "main idea" of test 4 or type test. I got AV. Need some reason where is my mistake (to my mind - arrays, but need help). Thanks. Try to do login or logout while no user is registered yet. It work's properly. Can u give me 1-2 tests? idk, try 100 register operations? 100 logins? 100 logouts? 1 register, 2 logins and 3 logouts? There aren't many possible cases really. I know that there is a lot of variants (arrays). Thanks. I'll try to solve. |
Runtime error 4 | Nextatix | 2002. Тестовое задание | 1 май 2015 19:59 | 1 |
switch(in.sval) { case "register": { in.nextToken(); log=in.sval; if(log==null) log=Integer.toString((int)in.nval); in.nextToken(); pas=in.sval; if(pas==null) pas=Integer.toString((int)in.nval); if(m.containsKey(log)) out.println("fail: user already exists"); else { m.put(log,pas); out.println("success: new user added"); } } break; case "login": { in.nextToken(); log=in.sval; if(log==null) log=Integer.toString((int)in.nval); in.nextToken(); pas=in.sval; if(pas==null) pas=Integer.toString((int)in.nval); if(!m.containsKey(log)) out.println("fail: no such user"); else if(!m.get(log).equals(pas)) out.println("fail: incorrect password"); else if(a.contains(log)) out.println("fail: already logged in"); else { a.add(log); //out.println(m.get(log) + " " + pas); out.println("success: user logged in"); } } break; case "logout": { in.nextToken(); log=in.sval; if(log==null) log=Integer.toString((int)in.nval); if(!m.containsKey(log)) out.println("fail: no such user"); else if(!a.contains(log)) out.println("fail: already logged out"); else { a.remove(log); out.println("success: user logged out"); } } break;
} |
WA4 | Alexey Stulov | 2002. Тестовое задание | 21 фев 2015 19:38 | 1 |
WA4 Alexey Stulov 21 фев 2015 19:38 please can anyone tell me what is the test of 4????? #include <iostream> #include <conio.h> using namespace std; struct abonent { char login[30]; char password[30]; short status; }; int main() { short n, k = 0, j, compare, index; char *part_str; char str[80]; cin >> n; abonent *peop = new abonent[n]; gets(str); for (int i = 0; i < n; i++) { gets(str); part_str = strtok(str, " "); if (!(strcmp(part_str, "register"))) { part_str = strtok(NULL, " "); strcpy(peop[k].login, part_str); compare = 1; for (j = 0; j < k; j++) { if (!(strcmp(peop[k].login, peop[j].login))) { compare = 0; break; } } if (compare) { part_str = strtok(NULL, " "); strcpy(peop[k].password, part_str); peop[k].status = 0; k++; cout << "success: new user added\n"; } else { cout << "fail: user already exists\n"; } }
if (!(strcmp(part_str, "login"))) { part_str = strtok(NULL, " "); compare = 1; for (j = 0; j < k; j++) { if (!(strcmp(part_str, peop[j].login))) { compare = 0; index = j; break; } } if (!compare) { part_str = strtok(NULL, " "); if (!(strcmp(part_str, peop[index].password))) { if (peop[index].status) { cout << "fail: already logged in\n"; } else { peop[index].status = 1; cout << "success: user logged in\n"; } } else { cout << "fail: incorrect password\n"; } } else { cout << "fail: no such user\n"; } } if (!(strcmp(part_str, "logout"))) { part_str = strtok(NULL, " "); compare = 1; for (j = 0; j < k; j++) { if (!(strcmp(part_str, peop[j].login))) { compare = 0; index = j; break; } } if (!compare) { if (peop[index].status) { peop[index].status = 0; cout << "success: user logged out\n"; } else { cout << "fail: already logged out\n"; } } else { cout << "fail: no such user\n"; } } } delete[] peop; return 0; } Edited by author 24.02.2015 02:52 |
Can someone help me with WA3? | Nikita Semenov[Kungur] | 2002. Тестовое задание | 11 ноя 2014 19:36 | 1 |
|
WA #1 | mikhsatyshev | 2002. Тестовое задание | 23 сен 2014 15:19 | 1 |
WA #1 mikhsatyshev 23 сен 2014 15:19 I don't understand why WA #1 because I fully tested answer of mu programm and answer on site. They hasn't got differences! Even invisible characters. Here is my code: var n,i,j,fl,k,n1:longint; a,b,d,x:string; y,z:array [1..100] of string; z1:array [1..100] of byte; c:char; begin readln (n); for i:=1 to n do begin fl:=0; a:=''; b:=''; d:=''; readln (x); n1:=length (x); j:=0; repeat j:=j+1; If x[j]<>' ' then a:=a+x[j]; until x[j]=' '; repeat j:=j+1; If x[j]<>' ' then b:=b+x[j]; until x[j]=' '; repeat j:=j+1; If x[j]<>' ' then d:=d+x[j]; until j>=n1; fl:=0; If a='register' then begin for j:=1 to k do If b=y[j] then fl:=1; If fl=1 then writeln ('fail: user already exists') else begin writeln ('success: new user added'); k:=k+1; y[k]:=b; z[k]:=d; z1[k]:=0;end;end; fl:=0; If a='login' then begin for j:=1 to k do If b=y[j] then fl:=j; If fl=0 then writeln ('fail: no such user') else If (fl>0) and (d<>z[fl]) then writeln ('fail: incorrect password') else If (fl>0) and (d=z[fl]) and (z1[fl]=1) then writeln ('fail: already logged in') else begin writeln ('success: user logged in'); z1[fl]:=1;end;end; fl:=0; If a='logout' then begin for j:=1 to k do If b=y[j] then fl:=j; If fl=0 then writeln ('fail: no such user') else If (fl>0) and (z1[fl]=0) then writeln ('fail: already logged out') else begin writeln ('success: user logged out'); z1[fl]:=0;end;end;end; end. |
At test 6 | [RISE] Levon Oganesyan [RAU] | 2002. Тестовое задание | 4 фев 2014 20:58 | 1 |
At test 6 [RISE] Levon Oganesyan [RAU] 4 фев 2014 20:58 more than one registrations ;) |
WA5 / Сan somebody tell whether it may be several current users at once? | bulka94 | 2002. Тестовое задание | 2 фев 2014 19:13 | 2 |
Сan somebody tell whether it may be several current users at once? Может кто нибудь сказать, может ли быть несколько текущих пользователей сразу? Edited by author 01.02.2014 02:35 Yep, there must be an array with all active users. Нужен будет еще один массив для записи текущих (login) пользователей, у кого будет выбивать WA5. |
Why TLE(time limited exceed)?(For help) | chenxingbei2 | 2002. Тестовое задание | 9 ноя 2013 22:01 | 2 |
Is n no more than 100? The time complexity of my program is O(n*n), why does it take so much time to run my program?(0.531s) Do we need O(n*log(n)) to solve this problem? Maybe your program do a lot of iterations? You can skip some iterations after you found an user... 1<=n<=100 :) |