| Show all threads Hide all threads Show all messages Hide all messages |
| Problem description | LaVuna [KHNURE] | 1221. Malevich Strikes Back! | 11 Jun 2026 21:17 | 2 |
You should find maximum matrix which is square, black and also contains white square inside rotated by 45 degrees. For instance: 1) 1 1 1 0 1 1 1 1 1 0 0 0 1 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 0 1 1 1 1 1 0 1 1 1 2) 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 0 1 1 1 1 are desired matrices maximum width of which you must find 1st matrix is invalid (pre-last row) |
| Can we do this in O(N) ? | Nikunj Banka | 1031. Railway Tickets | 10 Jun 2026 11:52 | 5 |
My solution runs in O(N logN) and it uses heap data structure. The discussion forums hint that there may be a O(N) time solution. Is there a linear time algorithm? heap?:D just use lower_bound And, BTW, Yes there is. At first I used Binary Search on each station but on the next station you can start with the previous index. code: int canReach1 = A[i] + L1; while (ind1 <= end && A[ind1] <= canReach1) ind1 ++; i've used dp (which is easy to notice) with some optimization. suppose we have three stations s1 s2 s3 and there exists path s1-s2 covered with l1, and path s1-s3 also covered with l1. then we can skip the analysis from s2. we can easily reduce used time if we create list of "allowed" stations to analyze (like s3) You can keep deque (FIFO) of pairs (max_x,total_price) if using C1 on last trip, same for C2, same for C3. All three deques will be non-descending on price (and naturally ascending on coordinate). At each step pick minimum from non-empty deques (their front element) and push new advances to their end. Edited by author 11.06.2026 06:16 |
| WA#11 | gepo | 1291. Gear-wheels | 10 Jun 2026 04:55 | 7 |
WA#11 gepo 26 Sep 2004 20:25 What means if gear-wheel have only one cog? Edited by author 26.09.2004 20:25 In this test have some gear not connect from other Try this test 2 1 0 1 0 1 6 answer 6/1 0/1 Edited by author 18.04.2005 12:50 |
| Hint | Solver | 2030. Awesome Backup System | 10 Jun 2026 04:19 | 1 |
Hint Solver 10 Jun 2026 04:19 There is simple O(N+M) algo (core part is like 5 lines), and it's "online" (no preprocessing of queries required) Edited by author 10.06.2026 04:20 |
| Small hint | andreyDagger`~ | 1155. Troubleduons | 10 Jun 2026 01:07 | 2 |
Notice, that you can move duons alongside diagonal (A->F, A->H, G->E, ...) Set up your own camera numbering. Change the C-D and H-G numbers. |
| Any Good algorithm?? My algo is O( H * W * ( 5 + 5 + 1 )^2 ). | c_pp | 1121. Branches | 9 Jun 2026 10:46 | 2 |
Who know O(H*W) or, O(H*W*5) algo ??? You can dynamically update amount of branches per-type per-distance for each horizontal step leading to O(W*H*9) Edited by author 09.06.2026 11:10 |
| best tests | Dmi3Molodov | 1800. Murphy's Law | 9 Jun 2026 05:55 | 2 |
It is much more interesting to look for good tests for this task than just to solve it. Here is the AC program (with a small error in order not to publish solutions). I will look for where it will fail. #include<iostream> #include<cmath>//too lazy to write sqrt() yourself int main() { unsigned l, h, o; std::cin>>l>>h>>o; unsigned phase = 0; if(l<h*2) phase = o*sqrt((2*h-l)/981)/15+1; char const*answer[]{"Butter","Bread\n"}; std::cout<<answer[(phase>>1)&1]<<std::endl; } |
| You can use a segment tree for brace balance checking | Levon Oganesyan | 1574. Mathematicians and brackets | 8 Jun 2026 21:12 | 2 |
Tree for minimum is enough. It's O(N) problem with O(1) memory (apart from string itself) |
| Answer can be negative | Igor Parfenov | 1300. Taxes | 8 Jun 2026 17:06 | 1 |
Input 0 50 10 0 0 100 200 -1 Output -5.00 I thought at first, that an absolute value has to be printed, which gets WA 3. |
| Could anyone provide me with an O(n) solution? My works O(n log(n)) | Sq1 | 1651. Shortest Subchain | 8 Jun 2026 15:30 | 2 |
Could anyone provide me with an O(n) solution? My works O(n log(n)) BFS for shortest path, but not over original graph - over the chain itself. There are edges of weight 1 and 0. |
| Accepted 0.156 2 993 КБ | TakeOver [MSU] | 1067. Disk Tree | 7 Jun 2026 23:42 | 4 |
Just used STL contaners such as std::map<std::string,T>, std::vector<T>. :) 33 lines of code. what is "T"? give please full description. I used a map and a set. My time was a little less than 2 times faster, and used a little more than 2 times more memory. struct dir { std::string name; std::map<std::string, dir*> children_items; std::set<std::string> children_names; }; The set gives you the sorted list. The map gives you instant access to a subdirectory of a given directory by name (taken from the set) Edited by author 29.12.2022 02:15 struct dir { map<string, dir> sub; } root; |
| WA test 8 | Henrique | 1588. Jamaica | 7 Jun 2026 02:24 | 3 |
plz help me, i got WA on this test , if someone knows this one help me!. I think it's a test like: 3 0 0 0 3 0 2 and I just adjust my program I did it using integers keeping unique lines (a,b,c) a*x+b*y=c so that gcd(a,b)=1, a>=0. Mistake for WA8 was that for a=0 I did not ensure b>0, i.e. (0,1,1) and (0,-1,1) were considered as different lines. |
| Better algorithm | LLM_AI_Testing | 1553. Caves and Tunnels | 6 Jun 2026 21:23 | 1 |
Use heavy-light decomposition: after O(N) preprocessing, every tree path becomes O(log N) contiguous ranges in the HLD order. Because cave radiation only increases, maintain range maximums with a monotone Fenwick tree, giving O(log N) per update and O(log^2 N) per path query with O(N) memory. Current #1 AC Edited by author 06.06.2026 21:24 Edited by author 06.06.2026 21:24 |
| Good test | Yermak | 1312. Tray | 4 Jun 2026 15:25 | 2 |
600 400 152 63 152 Solution exists. |
| AC at least, but for me this problem very strange! | coder | 1553. Caves and Tunnels | 4 Jun 2026 12:33 | 3 |
Heavy-Light-Decomposition -> GOOD data structure! thank you all! sqrt(n) decomposition also works here (0.5 sec) and easier to implement it's actually does not differ much because heavy-light with segment/fenvick over chains will be something like Q*log^2(N) with bad constant over it Actually it was the other way around :) except for ram usage SQRT: 0.437 11 532 KB HLD: 0.296 14 784 KB |
| Stack Overflow | Night | 1553. Caves and Tunnels | 4 Jun 2026 11:33 | 4 |
Please I got Crash(Stack Overflow), I implemented my first heavy-light descomposition and tried this problem, but I got this. I got AC, I had to convert the DFS to BFS, to evade the StackOverflow. Edited by author 02.11.2011 04:45 Edited by author 02.11.2011 07:20 Edited by author 02.11.2011 08:20 {$m 100000000000000000000} You can use "G++ 9.2 x64" language to avoid it You can also use #pragma comment(linker, "/STACK:16777216) for MSVC and both heavy-light or sqrt decompositions can be performed with BFS, so no recursion needed |
| Hint for WA #8 | Vedernikoff 'Goryinyich' Sergey (HSE: АОП) | 1524. Men in Black | 3 Jun 2026 22:56 | 1 |
Hint for WA #8 Vedernikoff 'Goryinyich' Sergey (HSE: АОП) 3 Jun 2026 22:56 Likely some rounding issue, e.g. in Python int(x + 0.5) => WA #8 int(x + 0.5 + 1e-9) => AC |
| hints (Nostradamus advised this) | Dmi3Molodov | 1401. Gamers | 3 Jun 2026 16:47 | 1 |
using u32=unsigned; u32 constexpr M = 9; u32 n = 0, g[1<<2*M]; template<u32>void solve(u32, u32=0); template<>void solve<2>(u32 voidXY, u32 BaseXY){ u32 e = n++, *p = g+BaseXY, q = g[voidXY]; *p = e, p[1] = e, p += 1<<M, *p = e, p[1] = e, g[voidXY] = q; } template<u32 s> void solve(u32 V, u32 B){ auto constexpr f = solve<s/2>; u32 constexpr m = (1<<M)-1; bool a = (V&~m)<(B&~m)+(s<<M)/2; bool b = (V&+m)<(B&+m)+s/2; f(V, B+(!a)*(s<<M)/2+(!b)*s/2); f(B-a*(1<<M)+b+((s<<M)+s)/2-1, B-a*(s<<(M-1))+b*s/2+(s<<M)/2); f(B+a*(1<<M)+((s<<M)+s)/2-(1<<M)-1, B+a*(s<<M)/2); f(B+a*(1<<M)+((s<<M)+s)/2-(1<<M), B+a*(s<<M)/2+s/2); u32*c = g+((s<<M)+s)/2-(1<<M)+B; c[m+(b&!a)] = c[(a&b)-1] = c[a<<M] = n++; } //this is a very funny, but working program code. Edited by author 03.06.2026 19:49 |
| WA #3 | 👨🏻💻 Spatarel Dan Constantin | 2139. Experiment with Juice | 2 Jun 2026 03:13 | 1 |
WA #3 👨🏻💻 Spatarel Dan Constantin 2 Jun 2026 03:13 Input: 3 -6 -9 9 -1 0 5 1.5 -5.0 2 -155 -292 Output: 11.571429 0.000000 0.000000 |
| TL 17 | ~'Yamca`~ | 1623. Fractal Labyrinth | 1 Jun 2026 23:09 | 1 |
TL 17 ~'Yamca`~ 1 Jun 2026 23:09 you can decompose path (i -> j) like (i -> x) + (x -> y) + (y -> j) or like (i -> y) + (y -> j) |