Common Board| Show all threads Hide all threads Show all messages Hide all messages | | AC | linjek | 1016. Cube on the Walk | 9 Jul 2026 02:00 | 2 | AC linjek 9 Aug 2014 16:51 You can solve that with algo Djikstra. We have 6!*8*8 vertex (hash of cube and point) . And all vertexs have <=4 edges. P.s. sry for English ) Edited by author 09.08.2014 16:51 Re: AC Solver 9 Jul 2026 02:00 there are only 24 orientations | | This is pretty simple task | Skeef79 | 2112. Battle log | 9 Jul 2026 01:27 | 2 | just use DSU to check teams, and then build answer why dsu? just bfs on revival links. if component >4 - FAKE. then fill up 3+1, 2+2, 2+1+1, 1+1+1+1 | | For WA6 | Ade | 1629. Trip | 8 Jul 2026 23:50 | 2 | The first day has no delay flight from the day before. 2 1 60 100 23:00 He can departure from 24:00 , not 00:00 Thanks, but with this change just for the 1st flight it gets WA13 :) The right solution is to get yesterday flights only when current time spent is >= 1440. Problem statement lacks "from this moment" phrase which exists in russian version. Edited by author 08.07.2026 23:57 | | O(W*H) solution passes | LaVuna [NULP] | 1235. Cricket Field | 8 Jul 2026 23:26 | 2 | O(W*H) solution passes Edited by author 22.08.2021 13:50 Edited by author 22.08.2021 13:50 I did it O(N^3) way, but can be done O(N^2*log(N)) Edited by author 08.07.2026 23:43 | | Doubts about using the random number. | MYLS | 1333. Genie Bomber 2 | 8 Jul 2026 16:57 | 4 | In my programme, I use 1000 000 random locations to check if the points are in the circle. At first, I wrote something like this: "double tx = ( double )( rand() % 101 ) / 100.0 ";(because: 0 ≤ x ≤ 1, -> rand() % 101 ∈[ 0, 100 ] );and just got WA...... Finally I changed the 101 into 100 and got AC; Can anyone tell me why 101 is incorrect? or it is actually right? You're just lucky that in the second case you got AC - actually good tests will kill your second solution as well, because what you generate is random point on integer grid 100 x 100 and this is far from random real point. Good way of generating random point in unit square is doing double(rand()) / RAND_MAX for both coordinates - this will give you point close enough to truly random. Thanks for your reply, I realize I have mixed up continuity and dispersion. :-) This contradicts the condition of the task. It is ALWAYS required to have the correct answer. Use regular points. | | How to solve it? | Fdg | 1772. Ski-Trails for Robots | 8 Jul 2026 14:30 | 5 | DP + sqrt-decomposition (or tree-like structure) I think that Djkstra in graph of robot's ends will work. No need for Dijkstra or sqrt decomposition :) Nodes are (0,s), (i,l[i]-1), (i,r[i]+1) where applicable. The main idea is that you do not have to bend towards edges if you can go in a straight line, you can always make that adjustment later when necessary at the same cost. However, tracing all these rays for every obstacle will quickly MLE/TLE. To work around this you need to answer quickly location of nearest obstacle further ahead. This can be done with going back-to-front and paint over segment tree with lazy propagation. Nodes which have no obstacles ahead going in a straight line are terminal nodes (start may also be such, then the answer is 0). So it's K*log(N) to track those nearest obstacles for each of K*2+1 nodes, and then easy BFS from left to right. And don't forget about int64. Edited by author 08.07.2026 23:27 (LLM-written, always verify, but current AC #1 beating all previous entries) There’s another O(k log n) way: treat the current answer as a function of the trail number. After each obstacle this function is still made only of `+1/-1` linear pieces, and processing an obstacle just replaces its blocked interval by at most two new pieces. A lazy segtree is enough. | | this test help me | ~'Yamca`~ | 2168. Runes in the Field | 8 Jul 2026 14:28 | 2 | WA8: 6 aabcaa ans: 6 RE9: 7 aaaaaaa ans: 7 Did use suffix automaton? Or give me any hint please. | | why I get wa on test 23? | Aneto | 1772. Ski-Trails for Robots | 8 Jul 2026 10:02 | 5 | Try it: 8 3 3 2 4 5 8 1 6 Answer: 6 What is the answer for the test: 10 5 2 2 8 4 6 ? Mine is 4. Am I correct? Or is the answer 6 or 10? L.E.: Nevermind I ACed. Answer is 4. Edited by author 22.09.2010 20:24 Edited by author 24.09.2010 01:45 I had RE23 because of this vector<int> l(n), r(n); // should be 'k' | | Any test data can help me? Always WA..I'm getting crazy! Thx! | Artanis | 1019. Line Painting | 8 Jul 2026 03:23 | 5 | I've tried many test data.But I always got wa on test data 8. Here is my code. And I'm sorry for my bad English- -! Waiting for your data! Thanks very much! program ural1019_3; var fill:array [1..5000,1..3] of longint; point:array [1..10003] of longint; col:array [1..10002] of byte; a,i,d,n,la,nn,x,y,u,yy:longint; c:char; procedure qsort(l,r:integer); var i,j,x,y:longint; begin i:=l;j:=r;x:=point[(l+r) div 2]; repeat while point[i]<x do inc(i); while point[j]>x do dec(j); if i<=j then begin y:=point[i];point[i]:=point[j];point[j]:=y; inc(i);dec(j); end; until i>j; if l<j then qsort(l,j); if i<r then qsort(i,r); end; procedure work; var a,i,b,ll,max,lr,ml,mr:longint; function x2find(p:longint):integer; var a,l,r,x:longint; begin l:=1;r:=nn; while l<r do begin x:=point[(l+r) div 2]; if p=x then break; if p<x then r:=(l+r) div 2-1; if p>x then l:=(l+r) div 2+1; end; x2find:=(l+r) div 2; end; begin for a:=1 to nn-1 do col[a]:=1; for a:=1 to n do begin i:=x2find(fill[a,1]); for b:=i to nn-1 do if point[b]<>fill[a,2] then col[b]:=fill[a,3] else break; end; max:=0;a:=1; while a<nn do begin while (col[a]=2) and (a<=nn-1) do inc(a); if a=nn then break; ll:=point[a]; while (col[a]=1) and (a<=nn-1) do inc(a); lr:=point[a]; if lr-ll>max then begin max:=lr-ll; ml:=ll; mr:=lr; end; end; if n<=0 then writeln('0 1000000000') else writeln(ml,' ',mr); end; begin readln(n);u:=n; for a:=1 to u do begin read(x,y,c); while (c<>'w') and (c<>'b') do read(c); readln; if x>y then begin yy:=x; x:=y; y:=yy; end; if x=y then begin dec(n); continue; end; fill[a,1]:=x; fill[a,2]:=y; point[a*2-1]:=fill[a,1];point[a*2]:=fill[a,2]; if c='w' then fill[a,3]:=1 else fill[a,3]:=2; end; point[n*2+1]:=0;point[n*2+2]:=1000000000; qsort(1,n*2+2); la:=1;i:=2; while i<n*2+2 do begin while (point[i]=point[la]) and (i<=n*2+2) do inc(i); if i>n*2+2 then break; inc(la); point[la]:=point[i]; end; nn:=la; work; end. Edited by author 27.07.2007 20:54 O my god.I checked it for 2 hours.Finally I found where I was wrong. Here is the data which showed me I was wrong. 11 1 999999999 b 5175 8925 b 2844 6891 w 1820 3903 b 8978 8978 b 4663 6345 w 316 1072 w 3197 7933 w 4124 4725 b 2832 3401 w 663 5756 w Correct answer is:316 7933 Hope it can help you. And sorry for my terrible English again. Edited by author 27.07.2007 22:46 Edited by author 31.07.2007 09:56 a very useful testcase indeed! > 8978 8978 b although does not affect result, ai<bi in problem statement | | Review | Igor Parfenov | 1482. Triangle Game | 7 Jul 2026 19:53 | 1 | Review Igor Parfenov 7 Jul 2026 19:53 The problem looks trivial at first glance. But I had never experienced such many corner cases. | | Simple problem or weak tests? | Fyodor Menshikov | 1424. Minibus | 6 Jul 2026 19:39 | 21 | My solution should use 2 * M * K indexations of linear array in the worst case (100 000 000 for max M and K) but works about 0.5s, twice less than time limit, and it is Java! Does it mean that so simple algorithm is enough or that tests are weak? Edited by author 15.05.2007 02:27 I used greedy algo, pascal, 0.265sec works, O(2*M*K) too. For such strong authors request of failed solver! Give us short clarification of this great optimization problem! What is more simple prototipe of it? What class of the problem? Graphs?DP? May be.... Timus Online Judge server is fast enough to perform more than 100000000 operations per second. The problem is based on the Activity Selection problem. Timus Online Judge server is fast enough to perform more than 100000000 operations per second. The truth of this statement depends on operation kind. Recently I solved problem in which 50 000 000 operations * and % on 64-bit integers worked 2s. Dmitry, do you know more precise numbers, how many operations of each kind the server can execute per second? For example linear array indexations - 180 bln, long multiplication - 100 bln and so on... Just write a kind of performance mark program, submit it and you will get exactly what you want. Then you may post the results here and everyone will appreciate your work. Is Activity Selection problem standard internet term? What is more simple prototipe of it? I don't know. What class of the problem? Graphs?DP? May be.... I'd said simulation. And I think Alexander Kouprin's definition "greedy" is right. The problem gets simpler if you change its model. You can allow driver to debus any boarded passenger at any stop < F[i] refunding the passenger all her money P. The driver in this case would get the same amound of money as if he would not board that debussed half-way passengers at all. Edited by author 15.05.2007 14:09I'd said it's sorting problem. :) You have segments of way: first point and last. Your task is how to combinate maximum of segment in K lines. This lines can be severed inside of itself and have big holes. I'd said it's sorting problem. :) I used sorting too, but I think the main problem is to devise what to do after sorting. I think it's a lecture hall assignment problem. One thing is that number of lecture halls here is limited by M... Thank for "lecture hall assignment" brand! I tried to solve it running Greedy-Activity-Selector M times. But WA at test 4. What is wrong with such approach? Gready _Activity_Selector of course. But with auxiliary subproblem: Let we have a set S={[ai,bi]} intervals chosen to some moment and according with greedy should include in S new segment [c,d]. Can we do it without excess of M. For, we must solve the problem of maximal overlapping value. I used augmented red-black tree as in Cormen but have very bad time 0.843 AC. Intuition says that good times taken due better ways of solving auxiliary problem. Edited by author 29.09.2007 14:41 Thanks, I realised that. I simply store now all stations beginnings in an array (maximum K). I initialise it with M value for each element. Now, for each request I go from start to end and check if all elements are non-zero (not including the end). If that requirement is met, I add the request to the result and decrement all checked elements By the way. Should we sort just time ending of the activity? In that case I get WA#4, If I sort beginnings in decreasing order in case of end equals, I get TLE #4 my algo is O(N + K *log(M)) -> AC in 0.1 i use segment tree and got AC in 0.109. what's the best algo? order of my algo is O((n+m)logn + klogk). GOOD LUCK!!! Segment tree with lazy propagation for amount of passengers at each station, so M is irrelevant. Passengers are bucket-sorted. O(K*log(N)+(N+K)) 0.062sec Edited by author 02.07.2026 06:52 (LLM-written, always verify, but AC 0.015s) Bucket passengers by start stop and sweep stops left to right; keep the currently accepted riding passengers in a structure that can return the one with maximum finish stop. When a passenger starts, accept him tentatively; if active accepted count becomes M + 1, delete from the active set the passenger with largest F. This greedy is safe because among simultaneously riding passengers, rejecting the latest-ending one frees capacity earliest for all future events compared with rejecting any earlier-ending one. With buckets plus a max-heap this is O(N + K log K); with a segment tree over finish stops it can be written as O(N + K log N). | | Why WA? Could anyboy help me? | sillyboy | 1169. Pairs | 3 Jul 2026 10:56 | 6 | My programme is: const nnn=100; var n,k,b,c,d,f:integer; a:array[1..nnn,0..(nnn-1)*nnn div 2] of shortint; e:array[1..100] of integer; begin readln(n,k); k:=n*(n-1) div 2-k; for b:=1 to n do e[b]:=(b-1)*b div 2; for b:=1 to n do begin for c:=0 to e[n] do a[b,c]:=-1; a[b,e[b]]:=0; end; for b:=1 to n do for c:=0 to e[b]-1 do for f:=b-1 downto 1 do begin d:=f; if c<e[b-d] then break; if a[d,c-e[b-d]]>=0 then begin a[b,c]:=d; break; end; end; if a[n,k]<0 then writeln(-1) else while n>0 do begin for b:=a[n,k]+1 to n-1 do writeln(b,' ',b+1); if a[n,k]+1<>n then writeln(n,' ',a[n,k]+1); if a[n,k]<>0 then writeln(a[n,k],' ',a[n,k]+1); b:=k; dec(k,e[n-a[n,k]]); n:=a[n,b]; end; end. I suppose you forgot that there are no cycles with 2 computers. try this input: 3 2 your output: 2 3 1 2 2 1 1 and 2 are connected twice, which is impossible. Hope this will help you. By the way, after you change your program, try such an input: 22 169 The answer is not -1 Good luck! I've got ac. Thank you for your help! I'm sorry but I think the answer for 22 169 is not -1. It is possible to construct such a graph. It's like this: 1-2-[3..6]-[7..14]-[15..22] ([a..b] means the clique of node a,a+1,...,b) Am I right? Or Is this graph wrong? And my program got AC. Could be a cycle as well for shorter output For 22 169 my AC gives this (tree of cycles rooted at 1) 22 169 1 2 3 4 4 5 5 6 6 3 1 3 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 7 1 7 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 15 1 15 | | This help understand statement about islands | 👑TIMOFEY👑 | 1250. Sea Burial | 3 Jul 2026 09:23 | 2 | Definition: "inside the island" Let's define the definition recursively: 1)If an island/sea touches the edge of the map, then it does not lie inside the sea/island 2)If an island/sea does not have internal seas/islands, then all the seas/islands it touches (it should be one if it does not touch the edge of the map) contain this island/sea inside themselves. 3)If an island/sea has internal seas/islands, then all these seas/islands in this island/sea, and all the seas of which these island/sea touch, which are not internal, contain this island/sea. this all means that if the island lies inside the sea, which is inside the island, which is inside the sea, which is inside the island that touches the end of the map, and the illuminated sea is selected, the sea that is inside the island touching the map, then all the islands inside the sea are not part of the island touching the end of the map, and if the outer sea is selected, then since it is not exactly contains an island touching the map, then it should not contain islands inside this island Another way - treat map as surrrounded not by the world ocean, but by a huge continent - i.e. write ##### around all borders, topology becomes pretty clear then. | | Странное условие. | -XraY- | 1250. Sea Burial | 3 Jul 2026 01:09 | 2 | Добрый день! Я сдал эту задачу, и у меня возникли трудности с условием. Во-первых, нигде не написано, что такое "внутри моря". Во-вторых, когда я догадался до значения вышеупомянутого термина, я не уловил смысла в следующем предложении: "Острова, касающиеся границы карты, не могут быть использованы для захоронений шаманов – шаманы этого очень не любят". Острова, находящиеся на границе, точно не лежат внутри никакого моря. В связи с этим, у меня возникло предположение, что ответ на следующий тест - 1 (что вроде неверно): 5 7 1 1 ..... .#### .#... .#.#. .#... .#### ..... (в ответ входит маленький островок справа). Поправьте условие, пожалуйста! Just surround map with ##### on every border, then it becomes clear Edited by author 03.07.2026 09:24 | | 0.031 seconds )) | coder | 2122. Hamming | 2 Jul 2026 15:59 | 1 | I found O(N^2) solution!!! | | Overrated | Keworker `~ | 1424. Minibus | 2 Jul 2026 01:34 | 2 | Problem is almost equal to 1203, there is really trivial solution if you now how to solve 1203. But rating of this problem is 711 and of 1203 is 82. It's strange) 1203 has only one seat, here we have segment tree dances on intervals | | WA on test 3 | Constantin Stefan | 1186. Chemical Reactions | 2 Jul 2026 00:52 | 2 | Can you give me more tests so i can check my programm? Any input i give him is solved correctly, no matter the size or the number of paranthesis. Please help! | | Wa 4 | Hououin`~`Kyouma | 2183. Good Mood | 1 Jul 2026 23:53 | 4 | Wa 4 Hououin`~`Kyouma 27 Jan 2025 12:32 Re: Wa 4 Combatcook [YarSU] 🐸 27 Jan 2025 19:06 "It is guaranteed that there exists at least one a_i < 0" So your test is incorrect Re: Wa 4 Hououin`~`Kyouma 28 Jan 2025 21:19 You're right. When solving this problem, I made the mistake of not selecting a segment at all and this test helped to find bug. I hope this helps someone. Edited by author 28.01.2025 21:20 Another helpful test 5 -4 5 -10 3 -10 Answer: -4 (not -5) | | Hint | Solver | 2216. Big Elevator | 1 Jul 2026 21:54 | 1 | Hint Solver 1 Jul 2026 21:54 Nice one about max-flow :) solvable at O(N*log(N)) by greedy propagation of most backward vertex using any of still unused elevators (did it using the farthest one, but it doesn't matter) Edited by author 01.07.2026 22:02 | | If you have WA8. | Lifanov | 1253. Necrologues | 1 Jul 2026 10:17 | 6 | Try this case 2 *2# hello *10# if N<10 '0' must be print. I think than N<=10 but N<10 Edited by author 22.10.2005 20:59 My program writes '#'. It is correct because we have a cycle, isn't it? The test that helped me on WA8: 3 *3*2 a# *3# b# right answer: "bb a" Thanx a lot it helped me too I had runtime (access violation) on 8 because I read all digits instead of just one, so *100 would reference out-of-bounds, it should be treated as {*1}00 |
|
|