Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Aho Carasick | sailingoat | 1269. Obscene Words Filter | 29 Jan 2025 22:36 | 1 | if MLE, avoid next[100001][256] and use a "flatmap" datastructure instead. (just store key-value pairs in dynamic array) | | Wa 26 | Hououin`~`Kyouma | 2192. My Grandfather | 29 Jan 2025 15:11 | 1 | Wa 26 Hououin`~`Kyouma 29 Jan 2025 15:11 | | Hint for WA12 | denxxjkee | 1074. Very Short Problem | 28 Jan 2025 22:38 | 2 | For WA12 try this: 9126492316491641269352615215701236589213658621356281376589216562319562396592381659862195621281E-190 100 # Output must be: 0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009126 Let me add some tests too: 1+ 1 -10.0- 1 My prog passed all tests from topics below but failed these. Output obviously must be "Not a floating point number" | | Пояснение по условию | Роман Спиркин | 1820. Ural Steaks | 28 Jan 2025 21:34 | 3 | Не совсем понял тестовый пример 3 2 то есть 3 котлеты и можно максимум 2 котлеты жарить в моменте вначале положим 2 котлеты с одной стороны потом эти же с другой стороны потом остается 1 котлета мы ее можем пожарить с одной стороны это 1 минута и ее же с другой то есть на нее необходимо 2 минуты значит всего необходимо 4 минуты почему ответ 3 ? как так пожарить Edited by author 11.06.2023 16:57 Edited by author 11.06.2023 16:57 Представь вот мы сначала жарим две котлеты с одной стороны, первую меняем на третью, а вторую переворачиваем. Жарим еще минуту и теперь у нас есть одна готовая котлета и две наполовину готовые, и дожариваем их еще минуту. Вот и получается всего три минуты. | | Wrong tests? | andreyDagger`~ | 2181. Student, or There and Back Again | 28 Jan 2025 19:01 | 6 | It seems like in test 7 n=300, m=300, k=0. Answer is obviously 709227659, but it gives WA. I also got answer 709227659 to this testcase. Yes, seems like incorrect tests or incorrect problem statement. Admins, please look at this issue. At least please check test 7. Also please, clarify order of N and M values in input data (if they go in M,N order then correct statement please). P.S. Also the problem is not so difficult as described in post-contest jury solutions. If problem statement is correct, it has got simple O(N*M) dp solution (based on https://en.wikipedia.org/wiki/Lindstr%C3%B6m%E2%80%93Gessel%E2%80%93Viennot_lemma principle). Yeah, jury solution is complicated. Mine solution is a bit different, but still straightforward O(N*M*(N+M)) dp, with simple O(1) transitions from each state Admins, any decision about this problem? Is test 7 correct? We fixed wrong tests. Original author miswrote 10^9+7 as 10000007 in his code, that generated incorrect tests. We sincerely apologize for such an error Edited by author 28.01.2025 02:06 Thanks a lot for solving the issue! Also, what about the original contest results ? ( https://timus.online/monitor.aspx?id=1568 ) Anybody now with correct tests has AC for problem M ? (suppose that such tests were on this contest too). Edited by author 28.01.2025 19:43 | | TO ADMINS | andreyDagger`~ | 1000. A+B Problem | 26 Jan 2025 15:07 | 3 | Why is this code gives Runtime Error? I think it's not a problem to allow participants use exceptions, as long as they are not throwing it out of main: #include <iostream> int main() { int a, b; std::cin >> a >> b; try { throw std::exception(); } catch (...) {} std::cout << a + b << "\n"; } For some old C++ compilers it was impossible to determine whether the exception is caught or not. At the same time there are very little practical use cases for using exceptions in C++ solutions. So, there was no reason in trying to fix the issue. I don't know if the modern compilers already made it possible to determine. But even if they do I would still keep this feature disallowed because it takes reasonable effort to verify that a not so popular feature works properly on each new version of each of the C++ compilers. Thanks for clarification. I was solving problem 1074 and thought it is a good idea to throw exception if parsing is failed somewhere in the depth of recursion. But yeah, this is the only problem from all of the archive where I wanted to use exceptions | | To Admins: Please, update Go(lang) compiler! | Aleksei Chernenkov | | 26 Jan 2025 11:32 | 1 | Hello! The latest update of compilers (in Jan 2024) missed Go(lang). Please, update it! Thank you very much! Edited by author 26.01.2025 11:33 | | Think simpler | sailingoat | 2199. Company Question | 24 Jan 2025 19:32 | 1 | Persistent segment tree is NOT NEEDED! | | Help WA44 | sailingoat | 2199. Company Question | 24 Jan 2025 19:04 | 1 | | | To admins: extending Python guide | Yury_Semenov | | 24 Jan 2025 05:13 | 2 | Recent Python versions contain a dangerous pitfall for people who use Python for solving bigint problems: https://docs.python.org/3/library/stdtypes.html#int-max-str-digits In short, converting large integers to string raises an exception unless you explicitly raise the limit with sys.set_int_max_str_digits(1000000). Since Python is quite popular for bigint problems and this pitfall is very easy to miss, especially when you have an older version locally, I suggest mentioning it in the Python guide. Thanks for pointing this out. I added this information to the Guide. | | To admins: Weak tests in problem 1514 | ixiolirion | 1514. National Park | 22 Jan 2025 05:08 | 2 | 8 0 0 10 0 5 10 15 10 16 11 166674 0 166675 10 1000000 0 My ACed program gives 32.3606797749979, but it should be 22.459574579560357. Your test added. 4 authors lost accepted solutions after the rejudge. Thanks! | | No tests when commission rate = 100? | v3n1v1c11v1c1 | 1283. Dwarf | 22 Jan 2025 04:44 | 2 | My two programs produce different results when initial gold > bad gold and commission rate is 100. 1. 10816824 2. 10816938 In fact, the commission rate is never 100 in the tests. I changed the problem statements to reflect that. I decided not to add such tests because it would affect a significant number of accepted solutions with a particular algorithm where this matters, while the solutions using other algorithms would stay unaffected. | | Is sample correct? | Oleg Alexeev | 2199. Company Question | 20 Jan 2025 22:21 | 2 | Why for Q: 1 6 the answer is 5 6 and not 2 6 ? Having input "17 11 -1 -4 20 -24" for 5 6 we have 20 -24 = -4 and for 2 6 we have 11 -1 -4 +20 -24 = 2 why -4 is better than 2? Because we need to find 2 separate indexes i < j : |a[i] + a[j]| is minimal. Not sum of segment |a[i]+a[i+1]+...+a[j]|, but only 2 numbers a[i] and a[j]. | | Test 4 | Flamel | 2182. Broken Rum | 19 Jan 2025 17:15 | 1 | Test 4 Flamel 19 Jan 2025 17:15 Guys please help with test 4 Can't pass it Admin! Please give test 4 Edited by author 19.01.2025 18:48 | | easy bfs | ~'Yamca`~ | 2174. Dualism of Numbers | 18 Jan 2025 19:12 | 1 | | | New problems 2174-2199 | Sandro (USU) | | 17 Jan 2025 01:47 | 1 | Selected problems from Ural contests of the last few years were added to the Problem set. | | Any hints? | Zergatul | 2119. Tree Hull | 16 Jan 2025 00:08 | 4 | My thoughts for now: - Generate list of parents for every node, as well as weight sum (2nd parent, 4th parent, 8th parent and so on). This will allow to calculate weight sum between two nodes in O(log N) - Implement LCA (better with O(1) time?) - Store root of subtree in variable - When new node comes, find LCA(new node, subtree root). 2 variants here: 1) LCA = new node (need to add sum of weights from new subtree root to previous subtree root) 2) LCA = existing subtree root. What to do here? - When we remove node? Sort v_i by depth-first order. d[v_i] is the sum of weights from the root to v_i The answer, when there are n nodes, is: sum_{i=1}^{n} d[v_i] - d[LCA(v_i, v_{i+1})]; where v_{n+1}:=v_1 Implement these operations using std::set with a custom comparator that orders vertices using depth-first order. The proof of the formula is left to the reader as an exercise. WOW, that's really smart. Thank you | | If you have WA @ 14 | sailingoat | 1527. Bad Roads | 15 Jan 2025 10:01 | 1 | Note that there can be parallel edges, hence it is wrong to imply degree <= 100 | | No need for Johnson or Hungarian. | sailingoat | 1076. Trash | 14 Jan 2025 11:12 | 1 | SPFA with edmond karp is enough. AC 0.06 (test might be weak) | | Can somebody send me a good algo of min cost max matching? I've found only O(N^4) | Jiang Xu | 1076. Trash | 14 Jan 2025 10:15 | 12 | Can somebody send me a good algo of min cost max matching? I've found a solution, but it runs in O(n^4), so I get time limit exceeded for some tests. > I've used a Hungarian algo that I've found on the NET. I don't know if it's correct because, for some tests it cycles to the infinite because no modifications can be done. Please, could somebody give me an algo that works? Here's my source. Usually it works fine but, as I said, in some cases it doesn't work. program trash; const nmax = 150; var a, d : array [1..nmax, 1..nmax] of integer; s : array [1..nmax] of integer; nz : array [1..nmax] of byte; m, b : array [1..nmax, 1..nmax] of boolean; hasm, found : boolean; mlin, mcol : array [1..nmax] of boolean; ming1 : integer; sum : longint; N, i, j : byte; procedure readdata; begin { assign(input, 'trash.in'); reset(input);} fillchar(s, sizeof(s), 0); readln(N); for i:=1 to N do begin for j:=1 to N do begin read(d[i,j]); inc(s[i], d[i,j]); end; for j:=1 to N do begin a[i,j]:=s[i]-d[i,j]; d[i,j]:=a[i,j]; end; readln; end; { close(input);} end; procedure DoZero; var i, j : byte; min : integer; begin for i:=1 to N do begin min:=a[i,1]; for j:=2 to N do if a[i,j]<min then min:=a[i,j]; for j:=1 to N do dec(a[i,j], min); end; for j:=1 to N do begin min:=a[1,j]; for i:=2 to N do if a[i,j]<min then min:=a[i,j]; for i:=1 to N do dec(a[i,j],min); end; end; function DoMark:boolean; var i, j, k, min, r : byte; begin fillchar(nz, sizeof(nz), 0); fillchar(m, sizeof(m), 0); fillchar(b, sizeof(b), 0); for i:=1 to N do for j:=1 to N do if a[i,j]=0 then inc(nz[i]); for k:=1 to N do begin {choose a row with min 0's} min:=255; for i:=1 to N do if (nz[i]>0)and(nz[i]<min) then begin min:=nz[i]; r:=i; end; if min=255 then begin DoMark:=false; exit; end; j:=1; nz[r]:=0; while (a[r,j]<>0)or(b[r,j]) do inc(j); m[r,j]:=true; {is marked} for i:=j+1 to N do if (a[r,i]=0) then b[r,i]:=true; for i:=1 to N do if (i<>r)and(a[i,j]=0) then begin b[i,j]:=true; dec(nz[i]); end; end; DoMark:=true; end; begin readdata; DoZero; while not DoMark do begin fillchar(mlin, sizeof(mlin), false); fillchar(mcol, sizeof(mcol), false); for i:=1 to N do begin hasm:=false; for j:=1 to N do if m[i,j] then begin hasm:=true; break; end; if not hasm then mlin[i]:=true; end; repeat found:=false; for i:=1 to N do if mlin[i] then for j:=1 to N do if (b[i,j])and(mcol[j]=false) then begin mcol[j]:=true; found:=true; end; if found then for j:=1 to N do if mcol[j] then for i:=1 to N do if (m[i,j])and(not mlin[i]) then begin mlin[i]:=true; found:=true; end; until not found; {i've made the marking} ming1:=maxint; for i:=1 to N do for j:=1 to N do if (mlin[i])and(not mcol[j])and(a[i,j]<ming1) then ming1:=a[i,j]; for i:=1 to N do for j:=1 to N do if (mlin[i])and(not mcol[j]) then dec(a[i,j], ming1); for i:=1 to N do for j:=1 to N do if (not mlin[i])and(mcol[j]) then inc(a[i,j], ming1); end; sum:=0; for i:=1 to N do for j:=1 to N do if m[i,j] then inc(sum, d[i,j]); writeln(sum); end. But how? Its complexity is O(n^4). I got TLE. Please, someone, tell me how to do it. no text Edited by author 12.12.2007 00:40 Usual mincost maxflow got easily AC here. I used maxflow with dijkstra to path searching. Dijkstra works O(n^2) ant increases flow by 1 eachtime. So we need only O(n) dijkstras to reach maxflow. Whole complexivity is O(n^3). In c++ is works for 0.171sec. How can you use Dijkstra since there are some edges which have minus values(values <0)? I used Bellman-Ford algo, and it doesn't run out of time. Use Dejkstra with potenciales. Modify weigth of eadges ... It's standart algorithm. I use SPFA but my problem got TLE with TEST#4 Testing machine is so fast now that an O(N^4) algo gets AC in less than 0.5s. Hungarian: 15ms Min cost flow with Dijkstra: 171 ms Min cost flow with optimized Bellman-Ford: 109 ms ¯\_(ツ)_/¯ What? How can min-cost flow with Dijkstra be used if negative edge exists (in residual graph)? Edit: Is it used with Johnson's potential. Edited by author 14.01.2025 10:15 |
|
|