Common Board| Show all threads Hide all threads Show all messages Hide all messages | | WA6 | andreyDagger`~ | 2026. Dean and Schedule | 26 Jan 2022 08:31 | 1 | WA6 andreyDagger`~ 26 Jan 2022 08:31 ????a 4 answer: zayba Edited by author 26.01.2022 08:53 | | If you have TL 50 or ML 50 | andreyDagger`~ | 1198. Jobbery | 25 Jan 2022 16:54 | 1 | Instead of writing this: vector<int> g[2001]; write this: vector<vector<int>> g;............g.resize(n + 1); Edited by author 09.06.2022 23:22 | | what wanted in this problem? | Md Ruhul Kuddus | 1025. Democracy in Danger | 24 Jan 2022 19:11 | 1 | I do here according to the test case description. But I need some hint what actually wanted in this problem. | | easy translation | Jamol Mattiev | 1991. The battle near the swamp | 24 Jan 2022 14:41 | 4 | if(a[i]<k){ ans+=k-a[i]; } else{ ans1+=a[i]-k; } I think that this problem is easy enough to try to make the solution as efficient as possible. My consideration notes: 1. You can make it without using arrays, because the local information that you get is enough to generate the answer. 2. I think that it is worth trying to make the speaking variable names. It will certainly require additional time, but I think, it should pay off in the future. Any good book (about Pascal for example) will tell about it Ho do they get 0.001 seconds? | | Test case N=0 (WA2) | Aleksei Chernenkov | 1290. Sabotage | 24 Jan 2022 12:35 | 1 | Problem description is very unclear on what to do when N=0. I believe that either * test case N=0 must be clarified or * lower bound of N must be set to 1. Hint: In current test suite the correct answer for N=0 is empty output. | | If you have Runtime Error with Python solution at 8-19 test | iron_orc | 1501. Sense of Beauty | 24 Jan 2022 03:27 | 1 | If using recursive algorithm increase recursion depth limit at least 4000. For my algo 2000 was not enough import sys sys.setrecursionlimit(4000) | | If you have WA#2 with Python solution but, for some reason, you are sure that your solution is a piece of Art | iron_orc | 1192. Ball in a Dream | 23 Jan 2022 20:30 | 1 | >>> print(round(0.0)) >>> 0.0 But "The output should contain the required distance in meters rounded to two fractional digits" So don't forget to use string formatting to provide 2 digits after comma Real test case: 5 90 2.50 0.00 | | Proof | andreyDagger`~ | 2003. Simple Magic | 22 Jan 2022 15:48 | 1 | Proof andreyDagger`~ 22 Jan 2022 15:48 This is proof of why answer < 3. Suppose, we have 3 elements x, y, z, with gcd(x, y, z) != 1. Then, after first transformation array will contain elements: gcd(x, y), gcd(x, z), gcd(y, z), Let's call them a = gcd(x, y), b = gcd(x, z), c = gcd(y, z). After second tranformation array will contain elements: gcd(a, b), gcd(a, c), gcd(b, c), we can notice, that: gcd(a, b) = gcd(gcd(x, y), gcd(x, z)) = gcd(x, y, x, z) = gcd(x, y, z). Doing similar things with gcd(a, c) and gcd(b, c), it turns out, that gcd(a, b) = gcd(a, c) = gcd(b, c) = gcd(x, y, z). That means, that after 2nd transformation array will contain 3 equal numbers greater than 1. I think it's obvious, that answer will be infinity, if array contains 3 equal numbers greater than 1. Now, if gcd of any tripple of numbers equals one, that means, that we will end in less than 2 transformations (Proof this by yourself) Edited by author 22.01.2022 15:49 | | AC. Take a look at my original solution :) | Anton Smoliakov | 1785. Lost in Localization | 21 Jan 2022 11:28 | 1 | var a: array[1..2000] of string; i: integer; begin for i := 1 to 2000 do begin if (i >= 1) and (i < 5) then a[i] := 'few'; if (i >= 5) and (i < 10) then a[i] := 'several'; if (i >= 10) and (i < 20) then a[i] := 'pack'; if (i >= 20) and (i < 50) then a[i] := 'lots'; if (i >= 50) and (i < 100) then a[i] := 'horde'; if (i >= 100) and (i < 250) then a[i] := 'throng'; if (i >= 250) and (i < 500) then a[i] := 'swarm'; if (i >= 500) and (i < 1000) then a[i] := 'zounds'; if i >= 1000 then a[i] := 'legion'; end;
readln(i); writeln(a[i]);
end. | | I got AC! Place your achievements here! | Access Violation | 1567. SMS-spam | 21 Jan 2022 10:04 | 4 | Edited by author 05.12.2007 18:27 How do you get 0.001 sec? I'm quite sure there's nothing to improve in my code. I get 0.015 sec using FreePascal. Where do I go wrong?? Как Вы достигаете 0.001 секунды? Я не вижу где можно улучшить код для FreePascal. Есть идеи? var c: array[32..122] of byte; n, i, sum: integer; s: string; begin c[32] := 1; c[33] := 3; c[44] := 2; c[46] := 1; c[121] := 1; c[122] := 2; for i := 97 to 120 do c[i] := (i - 97) mod 3 + 1; readln(s); n := length(s); sum := 0; for i := 1 to n do sum := sum + c[byte(s[i])]; writeln(sum); end. | | Please add 32-bit G++ back. | [ITMO] Semyon Stepanov | | 20 Jan 2022 21:25 | 1 | Your memory limits are too tight for 64-bit compilers and using 32-bit Visual C++ instead is not such a good idea because of its weird behavior. | | Please update rust | Egor Kulikov | | 19 Jan 2022 18:04 | 1 | Rust releases new version every 6 weeks. Even if this is too frequent please update it at least every half year | | Be carefull: non utf-8 characters in tests | Eugene Krokhalev | 1074. Very Short Problem | 19 Jan 2022 05:48 | 1 | Test #10 contains some non utf-8 characters. That could be the reason of panic if you use Go or Rust languages. | | Reason for WA#13 | dezaixing | 1039. Anniversary Party | 18 Jan 2022 19:53 | 10 | Just pay attention when Conviviality rating < 0. can you be more precise? Thank you! 11 5 4 3 2 7 1 1 1 1 1 1 6 4 7 4 8 4 9 5 10 5 11 5 4 3 5 3 3 2 2 1 0 0 Answer:15 15 Edited by author 02.08.2013 07:51 Edited by author 02.08.2013 08:04 Edited by author 02.08.2013 08:04 Edited by author 02.08.2013 08:04 спасибо тебе, это реально помогло мне I got WA#13 .But my dfs was a little wrong and I got ac after correcting it. I think all of subtrees of the current node should be calculated before the current node is calculated. Edited by author 24.10.2017 20:03 Edited by author 24.10.2017 20:03 | | Rounding hint | Olerinskiy | 1588. Jamaica | 16 Jan 2022 03:01 | 2 | floor(x) or round(x) - wa7 (int)x - OK Thank you. It helped me pass WA7 Edited by author 16.01.2022 03:01 | | Solution | miro.v.k | 2068. Game of Nuts | 16 Jan 2022 02:51 | 5 | Can anybody describe the solution please ? Нужно по индукции показать, что если у нас одна куча из 2*N+1 камней (N>=0),то ходов всегда будет ровно N. А далее игра идёт параллельно в каждой из куч(неважно какое разбиение в каждой из куч,т.к. кол-во ходов одно и тоже). Побеждает первый игрок, если кол-во ходов нечётно, иначе-второй Если я правильно понимаю, то тут нужно применять метод полной математической индукции. Итак, нужно доказать, что 2*N + 1 разыгрывается за N ходов. 1. Базис. При N = 0. В этом случае 1 куча из 1 камня. Чтобы её разыграть нужно 0 ходов. 2. Допустим, для всех n = 1 .. k утверждение верно. Докажем для n = k + 1. 2*(k + 1) + 1 = 2*k + 1 + 2. Эту кучу можно разложить на кучи (1, 1, 2*k+1), т.е. затратить на разбор кучи итого k + 1 ход (1 ход чтобы разложить на (1, 1, 2*k + 1) и k ходов из предоположения индукции на 3-ю кучу). кучу 2*k + 1 + 2 можно разложить и другими способами, т.е. это будет набор (2*k1 + 1, 2*k2 + 1, 2*k3+1), при этом 2*k1 + 1 + 2*k2 + 1 + 2*k3 + 1 = 2*k + 3 => k1 + k2 + k3 = k, т.е. доказали и без того очевидное, что ki < k, т.е. попадает под предположение индукции, кроме того, что после первого хода нам потребуется ещё k ходов и итого будет k+1. куеде. My intuition... First, why not try to reduce the numbers as less as possible? That would seem like playing more turns. Well, for a pile of size n, this would mean making piles 1, 1, n-2, and the first two won't be used anymore so we could say we reduced n by 2. Is this useful? How many times can we do this? Well, floor(n/2) times, or as n is odd, (n-1)/2 times. Now keep this number. Let's try to split into arbitrary sizes, n = n1+n2+n3. The last expression is (n1+n2+n3-1)/2. How many times can we reduce by 2 with the split piles? All of them are odd, so this is (n1-1)/2 + (n2-1)/2 + (n3-1)/2 = (n1+n2+n3-1)/2 - 1. So no matter what we do for splitting, this number is always reduced by 1! And this number essentially measures how many turns we can still play, so that's all, if this number starts odd, Daenerys wins. Edited by author 16.01.2022 02:52 | | A common mistake | D_G | 1585. Penguins | 14 Jan 2022 22:28 | 3 | I noticed a lot of people complain about WA2. Just wanted to share my experience, since I got WA2 several times. Don't forget that after you read the number, you haven't read the newline after it. So cin.getchar + cin.ignore and getline(cin, ...) get that exact newline. | | SPOILER: My proof on why solution idea works | John | 2025. Line Fighting | 14 Jan 2022 16:36 | 1 | So we must try to make teams have equal size. Why? Consider two teams with x and y members respectively, and consider x > y. Sending a member from first team to second team will only affect matches between these two teams. At first we have x*y different matches between the teams. If we send a player to the second team, there are now x-1 and y+1 members in each team. The matches are now (x-1)*(y+1) = x*y + (x-y) - 1 As we said x > y, x-y > 0, so x-y-1 >= 0 and our change can't reduce the total number of matches, so it is an optimal change. This also shows that nothing changes when x = y+1, so if we can't make all teams equal size, just add each of the ones remaining into a different team, making a difference of at most 1 in the sizes of teams. Now it's your job to compute the number of matches, I won't show that, but it can be done with a one line formula. Good luck :) | | greedy works! | khdz | 1303. Minimal Coverage | 14 Jan 2022 10:28 | 2 | I have solved this problem by using an easy greedy algorithm. MAIN: you need to use an idea of 2 pointers(of course you need to sort array) and take the rightest segment. Left part of segment need to be <= x(another pointer) The solution below: void solve() { int m; cin >> m; vector< pair<int, int> > pi; int a, b; cin >> a >> b; while (a || b) { pi.pb({a, b}); cin >> a >> b; } sort(all(pi)); int cnt = 0, j = 0; vector< pair<int, int> > ans; j = 0; int x = 0; for (; j < sz(pi) && x < m; j++) { int k = j; int mx = x; pair<int, int> par = {-INF, -INF}; while (k < sz(pi) && pi[k].ff <= x) { if (mx < pi[k].ss) { mx = pi[k].ss; par = pi[k]; } k++; } if (par.ff == -INF) { cout << "No solution\n"; return; } x = mx; ans.pb(par); if (k > j) j = k - 1; } if (x < m) { cout << "No solution\n"; return; } cout << sz(ans) << '\n'; for (auto &i : ans) { cout << i.ff << ' ' << i.ss << '\n'; } } always choose segments with rightest right points | | why difficulty is 121? | qualdum | 2142. Magic | 13 Jan 2022 00:08 | 2 | I dont understand why difficulty is 121, i think it's easy problem Not everyone is as super smart as you are, Anton. Us plebeians can barely walk upright, much less understand Western Arabic numerals. Congrats on your good fortune! |
|
|