Общий форумbe attentive with loop (while)! we know formule n - x * k =) and in depends of number parity condition will be >= (ex. [n - x * k >= n mod k] or [n - x * k >= k]). Good luck!) Edited by author 19.01.2023 16:23 Can anyone check if I missed any scenario ? 1, 2, 3, 4, 5 => Nothing to do here" 5, 4, 3, 2, 1 => Nothing to do here" 5, 2, 3, 4, 1 => "Yes\n1 5" 1, 8, 3, 4, 5, 6, 7, 2, 9 => "Yes\n2 8" 1, 8, 7, 6, 5, 4, 3, 2, 9 => "Yes\n1 9" 9, 8, 3, 6, 5, 4, 7, 2, 1 => "Yes\n3 7" 1 => Nothing to do here" 1, 1, 1, 1, 1 => "Nothing to do here" 9, 2, 3, 5, 4, 6, 7, 8, 1 => "No hope" 1, 2, 3, 9, 5, 6, 7 => "No hope" 7, 6, 5, 9, 3, 2, 1 => "No hope" 1, 1 => "Nothing to do here" 1, 2 => "Nothing to do here" 1, 2, 4, 3, 5, 6 => "Yes\n3 4" 6, 5, 3, 4, 2, 1 => "Yes\n3 4" 2, 1, 3 => "Yes\n1 2" 1, 3, 2 => "Yes\n2 3" 1, 2, 3, 2, 3, 4, 5 => "Yes\n3 4" 1, 5, 7, 2, 4, 5 => "No hope" If there are repeated digits, make sure you switch the right one. For example: 5 2 1 1 1 3 Try to generate tests containing a lot of same numbers, e.g. the next test: 9 1 5 1 3 3 3 5 1 5 has answer: Yes 2 8 WA-3: 1 2 3 .# #. .. 1 1 1 1 1 3 ----- NO WA-12: 3 3 3 .#. ... ... ..# ... ..# ... ... ... 1 2 2 3 3 3 ----- YES 2 climb east jump south WA-108: 1 1 1 . 1 1 1 1 1 1 ---- YES 0 Edited by author 11.08.2022 10:30 WA-3: 3 4 2 .#.. .#.. .#.. .... .... .... 1 1 1 3 4 1 ----- YES 5 walk south walk south climb east drop east walk east Interesting that test48, test70 (with reservations) and test80 do not look so hard to my solution. At least if the commenters in previous threads were right with examples of these tests. But mysterious test30 and test31 - I don't even imagine what structure they got. Test70 is "randomly" solvable: with time distributed between 0.3 and 2.9 seconds (with avg = 1.1 sec) on my Intel i5-9400 (by "randomly" - I mean, of course, that could be 2.9 seconds which is TLE and would not pass) And my suggestion: It would be nice to have a separate section on the site with parallel running of tests for such hard computational tasks. I mean: maybe someone also passes test 70, but fails test 30, for example. And the total percentage: passed N tests, failed tests with numbers K, L, M Now I know what's been wrong with my solution (TLE30), but now TLE46 If you read SPb-MaxBuzz's article about test generation for the problem, then you can see tests rearranged intentionally for top of solutions at some time point in the past. You can think your solution is very special. .................................................. .......................┌──────┐................... .......................│......│................... .......................│......│................... .......................│......│................... .......................│......│................... .......................│......│................... ┌────────┐.............│......│................... │........│.............└──────┘................... │........│........................................ │........│........................................ │─────┐..│........................................ │.....│..│........................................ │.....│..│........................................ │.....│..│..............┌──┐...................... │.....│..│..............│..│...................... └────────┘..............│..│...................... └─────┘.................└──┘...................... .................................................. .................................................. .................................┌┐............... .................................└┘............... ..┌──────┐.................................┌─────┐ ..│......│........┌────────┐...............│.....│ ..│......│........│........│...............│.....│ ..│......│........│........│...┌───┐.......│.....│ ..│.┌───┐│........│........│...│...│.......│.....│ ..│.│┌──││───┐....│........│..┌│──┐│.......│.....│ ..│.││..││...│....│........│..││..││.......└─────┘ .┌└─│───│┘┐..│....│........│..┌─┐──┘.............. .┌──└───┘.│..│....│........│..│.│.│............... .│...││...│..│┌─────┐......│..└─┘─┘............... .│...││...│..││...└─│──────┘...┌───┐.............. .│...││...│..││.....│..........│...│.............. .│...││...│..││.....│..........│...│.............. .└────┘──────┘│.....│........┌───┐.│.............. .│........│...│.....│........│.└─│─┘.............. .│........│...└─────┘........│..┌│................ .└────────┘..................│..└│................ .............................└───┘................ .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ..........┌─┐─┌─┐................................. ..........│.│.│.│................................. ..........┌─────┐................................. ..........│.....│................................. ..........│.....│................................. ..........│.....│.....................┌┌┐......... ..........│.....│.....................┌┐┐......... ..........│.....│.....................└┘┘......... ..........└─────┘................................. .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ..┌┐.............................................. ..└┌┐┌┐........................................... ...└┌└┘........................................... ....└┘............................................ .................................................. .................................................. ...............................┌┌┌┐┐┐............. ...............................└└└┘┘┘............. .....┌───┐........................................ .....│┘─└│........................................ .....││.││........................................ .....│┐─┌│........................................ .....└───┘........................................ .................................................. .................................................. .................................................. .................................................. .................................................. .................................................. ┌┌──┌┌──┐────┐┐───┌┐─┌───────┐─┌─────┌──┐┐───┌───┐ ┌│──│││││─│──│──┌─────────┐───┐┌────┐─┐┌││┐││││┐┐│ │││││││┌│────│──┌────┐─┘──││││││┌─────────┐──││──│ ││┌┌│└──┘─│─┌│┐─││││││││││││┌─│││││─││││┘│││─││─││ │┌──┌──┐──┘─┌───│──┐─│─┐──│┌───││┐│┐│─│───│┌─────┐ └│──││││││┌─│││─││┐│─│┐│└┌││──┘│││──││││││││──┘│││ └│──│──││─│┌────│──┐││││┌┐│││┌─└│───┘│││┌─││─────│ ┌│││└──┘┌─└│││──└────┘││└┘│││││┌││└─│─│┘│─││────┘│ ┌│┐││─┐│││││││││││││┌─┐│──││─│││││─┐││││││││││││││ │││─└──────││┘│┌│││││─││─┌││└│└─││──│─┘│││││─┐│┘││ └└─────││││││─│└││││└─┘│──│└────│┘││││─││┘│└─────┘ │││││││││─││└──────│──────┘└─│──│──┌│───┌──────┐─│ └─┘┌│┌─└│──│─────┌─│──┐│───┘┌└─┌└───────│─┘│┘│││││ ││└││││││└└│──┐──│─│──│┘─│└──│─│││││││─│││││─┌││─┐ ││┌─│┌──│─┐└───────┘││││││─│││┌│┐│││││││││││─└││││ ┌──┐││┘││││││─┌┐││─│││││┌┐─││││││││││──┘││───│││─│ ││└│└───└──└──└┘─│─└──││└┘──││└│┘│││││─┘│└────┘│││ │└└│─│┘─│││││──││└────┘│─┘─││└─└───└────│──┘┌└─│─┘ └──┘─│└─││││└───│──│──┘│────│─┘│─└─┘──┘─└──────┘─┘ └────└────┘└────└──────┘────└──────┘┘┘───└┘─┘─┘┘└┘ Edited by author 08.09.2019 16:59 Edited by author 08.09.2019 17:01 Edited by author 08.09.2019 17:01 Edited by author 08.09.2019 17:06 Edited by author 08.09.2019 17:06 Edited by author 08.09.2019 17:07 Edited by author 08.09.2019 17:07 Edited by author 08.09.2019 17:15 Wow! The last one is not with 15 square frames, but you did a great job! Thanx! #include <stdio.h> #define maxn 1000001 long n; short result[31],b[maxn]; int tr[maxn]; long count,i,j; main() { scanf("%ld",&n); for (i=0;i<n;i++) b[i]=0; b[1%n]=1; tr[1%n]=0; if (n!=1) b[2%n]=2; tr[2%n]=0; count=1; while (b[0]==0 && count <30) { count++; for (i=1;i<n;i++) if (b[i]!=0) { if (b[(i*10+1)%n]==0) { b[(i*10+1)%n]=1; tr[(i*10+1)%n]=i; }; if (b[(i*10+2)%n]==0) { b[(i*10+2)%n]=2; tr[(i*10+2)%n]=i; }; } } if (b[0]==0) { printf("Impossible"); } else { i=0; j=1; result[j]=b[i]; while (tr[i]!=0) { i=tr[i]; j++; result[j]=b[i]; } for (i=j;i>0;i--) printf("%d",result[i]); } getchar(); } When i had wa 10 i found out that my solution on test like 101 gives me 1212 instead of 1111. It doesnt helped me on this test, but i found mistake anyway var f,q,be:array[0..1000] of integer; n,x,a,b,c:integer; m:char; begin {assign(input,'1282.txt'); reset(input); } readln(n); for x:=1 to n do be[x]:=-3; for x:=2 to n do begin read(m); if m='L' then begin readln(a,b); if be[a]=-3 then begin inc(c); q[c]:=a; be[a]:=-1; end; if b=-1 then be[a]:=1; if (b=0) and (be[a]<0) then be[a]:=0; end else readln(f[x]); end; b:=1; while q[b]<>1 do begin if be[f[q[b]]]<-2 then begin inc(c); q[c]:=f[q[b]]; be[f[q[b]]]:=-1; end; if be[q[b]]=-1 then be[f[q[b]]]:=1; if (be[q[b]]=0) and (be[f[q[b]]]<0) then be[f[q[b]]]:=0; inc(b); end; if be[1]=1 then writeln('+1') else writeln(be[1]); end. {be[n]==the best value it then player play best f[n]==the father of n be[n]=-3===>it hasn't been visited } Read these sentences carefully: The leaf nodes of the tree of this game may have values equal to one of three numbers: “+1” – victory of the first competitor, “–1” – victory of the second competitor, “0” – draw. For example, Input 3 L 1 +1 L 1 +1 Output +1 Input 3 L 1 +1 L 1 -1 Output +1 Input 3 L 1 -1 L 1 -1 Output -1 Hope it can help:) The test 1 is different, and checks this condition. I tried to figure it out, how 1 tree and two sticks with the length of 2 can form the area more than 4? The largest area would be rectangle. What is the trick on this problem, can anybody explain with Geometry language. Thanks. The key point of the problem statement is "She knew that the standard football goal was rectangular, but, being creative, she assumed that her goal could have the form of an arbitrary quadrangle." So, it may be not a rectangle. I tried trapezoid like: /| 2/_| | | 2|__| x and tried to maximize the function - f(x) for total area which answer is sqrt(3) and total area is ~4.33 How to get ~4.8 for the given test? Try placing sticks a and b as follows: # #`. a # `. # `. x # \ # \ b # \ # \ ===================== y Hint: It can be proved that the area is maximal when x = y and angle between a and b is 135 degrees. If you get WA 30 check this: 1) correct calculation of tangent line angle (asin(2R/D), NOT asin(R/D)) 2) check not only enemies circles to make your movement, but angles to your own circles too. You can destroy your circles and win by this angle (don't forget about this). These tests helped me: Test 1: 7.100 2.280 3.530 4.410 2.690 2.990 1.770 4.360 5.850 1.770 1.960 1.720 6.550 1.870 2.200 4.940 4.090 0.920 6.580 3.590 1.970 1.070 2.390 2.700 0.360 4.030 1.520 6.730 5.820 5.280 1.640 5.520 Answer: WHITE Test 2: 2.670 6.880 2.140 2.820 0.830 6.960 2.180 4.600 6.220 7.170 7.130 1.290 3.010 6.320 2.880 4.690 0.350 6.670 6.680 5.820 7.230 5.020 7.160 4.100 0.120 0.430 2.950 7.780 5.630 2.400 2.290 1.310 Answer: RED Edited by author 06.01.2023 21:45 whats wrong with this logic? cout<<10-a<<" "<<10-b<<endl; All cans = Harry shot + Larry shot - 1; Not shot by Harry = All cans - Harry shot; Not shot by Larry = All cans - Larry shot; Edited by author 05.01.2023 23:48 This can be easily done on python 5 4 2 1 1 3 2 1 4 3 1 4 0 1 Impossible after 4 statements This solution is OK. But it not satisfy the restrictions. Your tests are too weak. #include <iostream> int main(int argc, char* argv[]) { int i= 0; for (i = 0; i < 1000000; i++) { printf("%c", rand()%26 + 'a'); } return 0; } I think that you miss conditions: Every possible subsequence with two letters length occurs not more than 2 000 times; Every possible subsequence with three letters length occurs not more than 100 times; I think with just a few tweaks, and "some" luck you can get AC on 1589. U HAVE VERY VERY VERY STUPID ERROR IN YOUR CODE #include <bits/stdc++.h> using namespace std; int main(){ long long n, res; vector <long long> vt; while(cin>>n){ vt.push_back(n); } int len = vt.size();
for(int i = len-1; i >= 0; i--){ double n = sqrt(vt[i]); printf("%0.4lf\n", n); } return 0; } Edited by author 07.09.2019 11:05 Edited by author 07.09.2019 11:11 while(cin>>n) .... Its an infinite loop. My AC solution also used while (cin >> n) double instead of long long while declaring n and vector. you can only use dfs , but don't forget to sort the team . When I use sorting as from short to long , I got TL , but when from long to short , only 0.02s ! I sort from long to short, but still Time Limited Exceeded. Can you tell me why? :) Edited by author 23.12.2018 21:36 Edited by author 23.12.2018 21:39 I was expecting TLE, because I use O(N^N), but in fact got AC in 0.015 I wonder if people who get TLE are doing something like O(N^N^N^π^e) lol Apparently, this is a very complicated problem, but 1115 allows solutions with naive implementations. I almost used brute force here, with some little optimizations (like looking for solutions for the next few sums while working on the 'current' one). |
|