Общий форум| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | | No subject | Andrey | 1493. В одном шаге от счастья | 12 ноя 2016 19:26 | 1 | #include <iostream> long int a,b,c,d,e,f,n,z,x,a1,a2; using namespace std; void main() { cin >>a; n=a%10; f=a%100; f=f/10; e=a%1000; e=e/100; d=a%10000; d=d/1000; c=a%100000; c=c/10000; b=a%1000000; b=b/100000; if ((n==9)||(f==9)||(e==9)) { z=(e+f+n)+1%10; } else { z=e+f+n; } if ((d==9)||(c==9)) { x=(b+c+d)+1%10; } else { x=b+c+d; } a1=z-x; a2=x-z; if ((a1==1)||(a2==1)) { cout <<"Yes"; } else { cout <<"No"; } } | | A few tests that helped me to find an error. | Victor Barinov (TNU) | 1058. Шоколад | 12 ноя 2016 02:53 | 3 | 4 0 0 1 0 0 1 -1 1 0.7071 3 0 0 1 0 0 1 0.6436 3 -1 0 1 0 0 1 0.9102 Thank you. But... C:\Casual\Task1058>task1058.exe <test12.txt 0.7071 C:\Casual\Task1058>task1058.exe <test13.txt 0.6436 C:\Casual\Task1058>task1058.exe <test14.txt 0.9102 I can hardly ever understand anything. My program cannot pass test #3. | | Tests | Islom(TUIT Urgench) | 1425. Ферзь 2 | 11 ноя 2016 18:24 | 1 | Tests Islom(TUIT Urgench) 11 ноя 2016 18:24 Test#1 3 3 1 2 3 ans:27 Test#2 2 6 1 3 ans:36 Test#3 3 6 3 4 5 ans: 180 Test#4 1 5 3 ans:5 Test#5 1 2 1 ans:1 Test#6 3 2 1 2 2 ans:4 | | 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 # 10? | muhiddin | 1881. Длинное условие задачи | 11 ноя 2016 12:30 | 5 | Pleae help. what is this test? Any input i get correct answer in my compiler.But here i get WA #10 2 4 5 a! a! a! a! a! try this, correct answer is 3, not 2 Thanks, I couldn`t understand where is a mistake) Why is it true? It should be 2, not 3! I got an AC after changing the input bufsize from 100 to 101. | | TEST | murdavron | 1809. Чапаев и картошка | 10 ноя 2016 10:52 | 1 | TEST murdavron 10 ноя 2016 10:52 Try this 1 1 2 2 3 3 4 4 2 change | | No subject | Md Shohel Rana | 1106. Две команды | 10 ноя 2016 09:22 | 2 | how can i see my current accepted submission rank???? http://acm.timus.ru/rating.aspx?space=1&num=1106Non language-specific rating; from there, you can select a language for a language-specific rating. However, it doesn't appear you have this task submitted, at least not from the account you've posted this message. Edited by author 10.11.2016 09:24 | | What wrong answer#3 | Deadpool | 2023. Дональд-почтальон | 10 ноя 2016 08:57 | 1 | #include<iostream> using namespace std; int n,i,k,t,j; string a[10000],b[10000],c[10000],d[10000]; int main(){ a[1]="Alice"; a[4]="Phil"; a[7]="Phoebus"; a[2]="Ariel"; a[5]="Peter"; a[8]="Ralph"; a[3]="Aurora"; a[6]="Olaf"; a[9]="Robin";
b[1]="Bambi"; b[4]="Mulan"; b[7]="Silver"; b[2]="Belle"; b[5]="Mowgli"; b[8]="Simba"; b[3]="Bolt"; b[6]="Mickey"; b[9]="Stitch";
c[1]="Dumbo"; c[4]="Kuzko"; c[7]="Tarzan"; c[2]="Genie"; c[5]="Kida"; c[8]="Tiana"; c[3]="Jiminy"; c[6]="Kenai"; c[9]="Winnie"; cin>>n; for(i=1; i<=n; i++) cin>>d[i]; for(i=1; i<=n; i++) { for(j=1; j<=9; j++) if(d[i]==a[j]){ if(t==0) k+=0; if(t==1) k+=1; if(t==2) k+=1; if(t==3) k+=2; t=1; break; } for(j=1; j<=9; j++) if(d[i]==b[j]){ if(t==0) k+=0; if(t==1) k+=1; if(t==2) k+=1; if(t==3) k+=1; t=2; break; } for(j=1; j<=9; j++) if(d[i]==c[j]) { if(t==0) k+=0; if(t==1) k+=2; if(t==2) k+=1; if(t==3) k+=1; t=3; break; } } cout<<k; } | | what's wrong? | Ehcalahim | 1106. Две команды | 9 ноя 2016 23:56 | 1 | what's wrong with this code: #include <iostream> #include <vector> #include <list> using namespace std; int ar[102][102],viz[102]; int n; list <int> a; int dfs(int s) { viz[s] = 1; for (int i=1;i<=n;i++) { if (ar[i][s] && !viz[i]) {dfs(i); }//a.push_back(i);} } return 0; } int main() { cin >> n; int z; for (int i=1;i<=n;) { cin >> z; if (z == 0) i++; else ar[i][z] = 1; } dfs(1); for (int i=1;i<=n;i++) if(!viz[i]) a.push_back(i); cout << a.size() << endl; for (int n : a) { cout << n << " "; } return 0; } maybe i didn't understand problem properly,some help? | | Help requested | Erast V. Kunenkov | 1134. Карты | 8 ноя 2016 17:36 | 11 | Here is my solution and used test cases. I don't understand why I always get WA. 8-( Test 1. 5 4 2 0 1 2: NO Test 2.5 4 2 0 1 5: YES Test 3. 5 4 2 0 3 5: YES Test 4. 5 4 2 0 3 4: YES Test 5. 5 5 2 0 3 4 5: YES Test 6. 5 5 2 0 2 4 5: YES Test 7. 5 6 2 1 2 4 5 0: NO Test 8. 5 4 1 2 2 3: YES Test 9. 5 5 1 2 3 4 3: YES Test 10. 5 5 1 1 0 3 4: NO Test 11. 5 3 0 0 1: NO Test 12. 5 3 0 1 1: NO Test 13. 5 3 1 2 2: YES Test 14. 5 3 1 1 2: YES Test 15. 5 3 4 4 5: NO Test 16. 5 3 3 4 4: YES Test 17. 5 3 4 5 5: NO Test 18. 5 3 3 4 5: YES Test 19. 2 2 1 1: YES Test 20. 2 2 2 2: NO Source code: [code deleted] Edited by moderator 13.02.2007 20:57 If the num of cards is lower than m i think that the asnwer should be NO 2.5 4 2 0 1 5 YES? Edited by author 19.01.2007 12:34 I'm not very good in C, and i don't undrstand your source) But my idea is very simple. Store in array number of repeats, increment a[0] and a[n] (because it's only one card with this numbers) and find in array sequence 2 1 1 .. 1 1 2 that's all) Edited by author 22.04.2009 22:45 i think so.i think that test#9 may be wrong.or i made mistake while reading the problem... tell the truth,i don't really understand the problem .. I don't understand Test 5. 5 5 2 0 3 4 5: YES Why? first 5 so take 5 or 6 second 5 so take 5 or 6 so take 5 and 6 ... last 5 so take 5 or 6 again, but 5 and 6 were taken, so NO help me, please for the 1st and the 2nd 5 means n and m without meaning the number which was took. here are test right Edited by author 31.12.2012 02:08 Edited by author 31.12.2012 02:08 Edited by author 31.12.2012 02:08 | | idea | Uttam Khanal | 1731. Укроп | 8 ноя 2016 09:43 | 1 | idea Uttam Khanal 8 ноя 2016 09:43 there are n * m possible sums. to find a solution, we can try to create such vectors such that all n * m sums are different. Suppose the 1st vector is 1 2 3 ... n Then the first element of next vector is taken to be n + 1(we require all unique). Now we need to find the next element while making all n*p sums different, where p is the size of the 2nd vector. n+1 1 2 3 ... n initially all sums(n+2 to 2n+1) are distinct. Now we need to add new element such that smallest possible new sum is greater than the previous sum i.e. if new element is p p+1>2n+1 or p >= 2n + 1 in general p+1>prev+n p>=prev+n | | I Have WA#4 | coder | 1926. Турнир интеллектов | 8 ноя 2016 00:03 | 1 | what is wrong here? for (int i =0; i< 15;++i) { int p = primes[i]; if ( c % p == 0) { unsigned long long M = c / p; unsigned long long M_inv = inverse[i][ M % p ] ; unsigned long long h = M_inv * m[ i ]; // r = (r + h * M ) % c unsigned long long high_M = (M >> 32 ) & 0xFFFFFFFFULL; unsigned long long low_M = ( M & 0xFFFFFFFFULL); // h * M= h * (high_M * 2^32 + low_M) unsigned long long high_h = high_M * h; unsigned long long e = (high_h >> 32) & 0xFFFFFFFFULL; unsigned long long f = (high_h & 0xFFFFFFFFULL); // high_h = e*2^32 + f // h*M = h*(high_M*2^32 + low_M) = high_h * 2^32 + low_M * h = // = (e*2^32 + f)*2^32 + low_M * h = e*2^64 + f*2^32 + low_M * h e = (e << 48) % c; e = (e << 3 ) % c; e = (e << 3 ) % c; e = (e << 3 ) % c; e = (e << 3 ) % c; e = (e << 3 ) % c; e = (e << 1 ) % c; e = (e + (f << 32) ) % c; e = (e + low_M * h ) % c;
r = (r + e ) % c; } } | | Can you help me!? Why this approach is correct? | Alibi | 2025. Стенка на стенку | 7 ноя 2016 22:50 | 2 | You have to divide the participants into equal teams (rounded) For example, for "15 10" test - (1, 1, 1, 1, 1, 2, 2, 2, 2, 2) Good luck :) Well I don't understand this topic CLEARLY but I can trace some steps towards the final solution. Let's fix a possible team distribution i.e. number of teams Then, we need to find the best possible distribution to maximize the product For eg for 4 teams a1,a2,a3,a4 will be the team distribution a1+a2+a3+a4=n now we need to maximize the function f(a1,a2,a3,a4)=a1a2+a1a3+a1a4+a2a3+a2a4+a3a4 under the constraint a1+a2+a3+a4=n, which can be done using lagrangian multiplier. g(a1,a2,a3,a4)=f(a1,a2,a3,a4)+p(n-a1-a2-a3-a4) lets take derivative of the function g at a1 g'(a1) = a2+a3+a4 -p g'(a2) = a1+a3+a4 -p g'(a3) = a1+a2+a4 - p g'(a4) = a1+a2+a3 - p Equate all of them to zero a1+a2+a3=a2+a3+a4=a1+a3+a4=a1+a2+a4=p from 1st and second we find a1=a4 from 2nd and 3rd a2=a1 similarly we find a1=a2=a3=a4, all a's must be equal so a1+a2+a3+a4=n a1=n/4 In general a1=n/p, where p is the number of teams. When p is not divisible, we need to make all of them as equal as possible by distributing n % p. I don't understand lagrangian multiplier by heart(I have not tried to). But the tool works here. We can try bruteforcing all possible team numbers from 2 to k and find which is best. Edited by author 07.11.2016 22:51 | | Why WA1? | ahmetov14 | 2031. Числа-перевёртыши | 7 ноя 2016 22:26 | 1 | int n = in.nextInt(); int l = 0; if (n > 24) { out.print("Glupenky Pierre"); } else { for (int i = 1; i <= n; i++) { if (i / 5 == 0) l = 0; if (i / 5 == 1) l = 1; if (i / 5 == 2) l = 8; if (i / 5 == 3) l = 6; if (i / 5 == 4) l = 9; if (i % 5 == 0) l = l * 10; if (i % 5 == 1) l = l * 10 + 1; if (i % 5 == 2) l = l * 10 + 8; if (i % 5 == 3) l = l * 10 + 6; if (i % 5 == 4) l = l * 10 + 9; if (l/10==0) out.print("0"); out.print(l); out.print(" "); } } Edited by author 07.11.2016 22:26 Edited by author 07.11.2016 22:27 | | Why I get WA? Pelase, help me!!!!!!! | Revenger and NSC | 1134. Карты | 7 ноя 2016 17:55 | 4 | There is my code: Program t1134; Const MaxN=1000; Var Card : array[1..MaxN]of boolean; Numb : array[1..MaxN]of integer; Use : array[1..MaxN]of boolean; M,N,i,j : integer; ex : boolean; begin Read(N,M); if (M>N)or(m=0) then begin writeln('NO'); halt(0); end; for i:=1 to N do Card[i]:=false; for i:=1 to M do Use[i]:=false; for i:=1 to M do begin read(Numb[i]); if (Numb[i]<0)or(Numb[i]>n) then begin writeln('NO'); halt(0); end; end; for i:=1 to M do if Numb[i]=0 then begin Use[i]:=true; if Card[1] then begin writeln('NO'); halt(0); end; Card[1]:=true; end else if Numb[i]=n then begin Use[i]:=true; if Card[n] then begin writeln('NO'); halt(0); end; Card[n]:=true; end; for i:=1 to m-1 do if not(use[i]) then for j:=i+1 to m do if not(use[j]) then if numb[i]=numb[j] then begin if (card[numb[i]])or(card[numb[j]-1]) then begin writeln('NO'); halt(0); end; card[numb[i]-1]:=true; card[numb[i]]:=true; use[i]:=true; use[j]:=true; end; repeat ex:=true; for i:=1 to m do if not(use[i]) then if (card[numb[i]])or(card[numb[i]-1]) then begin if (card[numb[i]])and(card[numb[i]-1]) then begin writeln('NO'); halt(0); end; if card[numb[i]] then begin card[numb[i]-1]:=true; use[i]:=true; end else begin card[numb[i]-1]:=true; use[i]:=true; end; end; until ex; Writeln('YES'); end. 3 3 2 2 3 Maybe you forgot something, because the output of your program for this test case is 'YES'; hope this will help Good luck! > 3 3 > 2 2 3 > Maybe you forgot something, because the output of your program for > this test case is 'YES'; > hope this will help > Good luck! > i suppose the answer should be NO for that 2 2 means the 2nd and the 3rd had been taken, so the third number 3 is uncorrect 3 3 2 2 3 Maybe you forgot something, because the output of your program for this test case is 'YES'; hope this will help Good luck! | | TEST#6 | sano23 | 1306. Медиана последовательности | 7 ноя 2016 02:21 | 1 | TEST#6 sano23 7 ноя 2016 02:21 does anyone knows test 6? | | Don't know why wrong | Lucas False | 1002. Телефонные номера | 7 ноя 2016 00:48 | 1 | | | Don | Lucas False | 1002. Телефонные номера | 7 ноя 2016 00:47 | 1 | Don Lucas False 7 ноя 2016 00:47 | | Где описание на русском? | obukkhov | 1044. Счастливые билеты. Easy! | 6 ноя 2016 19:34 | 3 | У задачи отклеилось описание на русском? Хоть и шарю по английскому, всё равно неприятно тратить несколько минут на перевод... Edited by author 20.02.2016 16:49 Если шаришь, скорость восприятия текста не может отличаться в разы. Для многих старых задач, по-видимому, русскоязычного условия в природе не существовало (1043 с того же контеста и тоже без русской версии). Когда-то и меня заботила мысль, а что же делать, когда дорешаю все переведённые задачи с тимуса. Но английский выучился быстрее :D | | explanation to N%3 | jagatsastry | 1180. Игра с камушками | 6 ноя 2016 16:32 | 6 | i see N%3 solution everywhere but does anyone have any explanation as to why the guy who has mod-3 no of stones should lose. Some logical or mathematical reason would be much appreciated. Let's see that for every number k which is an integer power of 2, k mod 3 = 1, or 2. (To be exact - table of (k mod 3) for {1,2,4,8,16,32,64... is: {1,2,1,2,1,2,1,2,1,2,... So, you can see that it is impossible to get from (mod 3 = 0) position to another (mod 3 = 0) position in one move. Let n (number of remaining stones) = 3. The first player can make x=1 or x=2 move, but now the second player can counter by making 3-x move and win. So n=3 is a losing position. We have proven that it is impossible to get from one number of stones divisible by 3 to another number of stones divisible by 3 in one move. We can now prove, by the rule of mathematical induction, that every position with n divisible by 3 is a losing position. Let's look - if the first player begins from position with 3*x stones, after any move the opponent can counter by '1' or '2' move and create another position with lesser number of stones, also divisible by 3. In the second case, when first player begins from position with number of stones not divisible by 3 (so n%3=1 or n%3=2), _he_ can now make a '1' or '2' move which will create a (mod 3 = 0) position (which was proven to be losing) for his opponent. Thus, due to arbitrarity of n, any (n mod 3 != 0) position can create a losing position for the second player in one move, so it is a winning position for the first player. Consider these. number of leave stones 1 win 2 win ---- because we can choose 1 or 2 3 lose sure ---- because if you choose 1 number of leave stones == 2 or if you choose 2 number of leave stones == 1 each player will be the winner. 4, 5 win, choose 1, 2 sure each player will be take 1 or 2 sure you will be the winner. 6 lose 7, 8 win .... we can assume if N mod 3 == 0 sure that person will be lose, otherwise we can choose the minimum of first number of stones = N mod 3 so each player will be the loser.
Also we can consider a Grandy function for n from 1 to .... g[0] = 0 g[1] = 1 g[2] = mex{0, g[1]} = 2 g[3] = mex{g[1], g[2]} = 0 g[4] = mex{0, g[2], g[3]} = 1 g[5] = mex{g[4], g[3], g[1]} = 2 ...... g[n] = n%3 More strictly can be proved using mathematical induction |
|
|