| Show all threads Hide all threads Show all messages Hide all messages |
| help (python) | quarylaniel | 1880. Psych Up's Eigenvalues | 2 Mar 2022 23:20 | 1 |
cnt = 0 a = int(input()) a1 = list(map(int, input().split())) b = int(input()) b1 = list(map(int, input().split())) c = int(input()) c1 = list(map(int, input().split())) for i in a1 : if i in b1 and c1 and a1 : cnt += 1 print(cnt) what is wrong? tells "wrong answer" |
| WA 26 | andreyDagger | 1966. Cycling Roads | 2 Mar 2022 19:41 | 1 |
WA 26 andreyDagger 2 Mar 2022 19:41 Probably you're getting overflow |
| WA 6 | andreyDagger | 1484. Film Rating | 2 Mar 2022 18:48 | 1 |
WA 6 andreyDagger 2 Mar 2022 18:48 Arithmetic average is not exacltly x. Due to the rounding arithmetic average can be x + 0.01 or even x + 0.04999 |
| WA8 test case | † SiriuS † | 1966. Cycling Roads | 2 Mar 2022 11:27 | 1 |
\/ \/ /\ /\ 8 4 0 0 2 2 2 0 0 2 0 3 2 5 2 3 0 5 1 2 3 4 5 6 7 8 Answer: "NO" |
| Bad statement | andreyDagger | 2121. Intersection of Parabolas | 27 Feb 2022 17:09 | 1 |
Spent a hour to realise that you don't need to count left and right parts of figure, only middle |
| No subject | emhope | 1177. Like Comparisons | 27 Feb 2022 01:55 | 1 |
Edited by author 27.02.2022 15:58 |
| How can the program recognize when there aren´t more inputs ? | Albert | 1001. Reverse Root | 26 Feb 2022 22:10 | 3 |
I investigated on internet, but most of the answers were putting a type of character that breaks the cycle, but in the input example there´s no character and it´s not enough with a "while(cin >> n)" pls help if copypast test text, it read a blank string as EOF by some reason Edited by author 26.02.2022 22:11 |
| Idea | __Andrewy__ | 1324. Extra Spaces | 26 Feb 2022 01:26 | 1 |
Idea __Andrewy__ 26 Feb 2022 01:26 Let's sequence S(n) = {s[1], s[2], ..., s[n]} is optimal sequence for the first n steps. L[i] is max number when we can get one space using S(n) for any number in range [1..L[i]]: firstly, we apply s[n], then s[n-1] and etc. Now let's get next s[n+1]. Suppose we found s[n+1] and want get L[n+1]. Always L[n+1] + 1 = q*s[n+1] + r, 0<=r<s[n+1]. L[n+1] is max number => for L[n+1] + 1 we need at least n+2 steps => q + r >= L[n] + 1. But L[n+1] + 1 is min number when using S(n+1) we can't get one space => r->max, q->min => r = s[n+1] - 1, q = L[n] + 1 - r => L[n+1] + 1 = q * s[n+1] + r => L[n+1] = (L[n] - s[n+1] + 2) * s[n+1] + s[n+1] - 2 -> max (where arg is s[n+1]) => s[n+1] = (L[n] + 1) / 2 But using symmetry we can give s[n+1] = floor(L[n] / 2) + 1 (we choice bigger number because s[2] > 1). => L[n+1] = q * s[n+1] + r - 1, q = L[n] + 1 - r, r = s[n+1] - 1.
Edited by author 26.02.2022 01:27 Edited by author 26.02.2022 01:27 |
| WA #1 | Alexandr Shchukin | 1112. Cover | 24 Feb 2022 23:04 | 1 |
WA #1 Alexandr Shchukin 24 Feb 2022 23:04 My program runs any tests from other topics perfectly, but something is wrong with the task 1. Sounds like madness. Edited by author 24.02.2022 23:04 Edited by author 24.02.2022 23:05 |
| If you don't understand first sample | andreyDagger | 1710. Boris, You Are Wrong! | 21 Feb 2022 17:06 | 1 |
Pay attention, that points given in order A, B, C. That means that angle of your triangle must equal to angle BAC Edited by author 21.02.2022 17:07 |
| WA9 | George_Aloyan[PTS Obninsk] | 1184. Cable Master | 21 Feb 2022 16:47 | 2 |
WA9 George_Aloyan[PTS Obninsk] 11 Jan 2012 22:27 Set types as long long for variables used as sum of cables lengths Re: WA9 Name-must-be-given-in-English 21 Feb 2022 16:47 For me, what worked was replacing "%i"'s with "%d"'s in scanf's. :) |
| WA #5 | Tapti | 1306. Sequence Median | 21 Feb 2022 15:54 | 1 |
WA #5 Tapti 21 Feb 2022 15:54 You should write "fixed<<setprecision(15)", because you get uncorrected format of numbers with dot |
| WA6 | andreyDagger | 1690. Army of Mages | 21 Feb 2022 15:18 | 1 |
WA6 andreyDagger 21 Feb 2022 15:18 There's negative numbers, that's mean if you're solving problem with C++, remainder will be calculating wrong |
| If you cant understand what you must do (Объяснение алгоритма) | Alexandr | 1925. British Scientists Save the World | 21 Feb 2022 09:47 | 1 |
Определим переменную difference Затем для каждого элемента истории прибавляем к difference разницу между числом с компьютера - 2 и введённым числом В конце проверяем k - 2 + difference, если оно меньше нуля, то мы в пролете, иначе вывести число |
| C++ What's wrong? | Ilia | 1001. Reverse Root | 20 Feb 2022 01:03 | 3 |
#include <iostream> #include <vector> #include <cmath> using namespace std; int main() { double val = 0; vector<double> v; char ch = 0; while (cin >> val) { v.push_back(val); } for (int i = 0; i < v.size(); i++) { cout << sqrt(v[i]) << endl; } } OK. Read this carefully: "For each number Ai from the LAST one till the FIRST one..." Second for loop cout from last element of the vector to first |
| AC | linjek | 1029. Ministry | 19 Feb 2022 12:11 | 3 |
AC linjek 7 Aug 2014 22:39 I solved this problem with algo of Dijkstra. Edge : (i,j)->(i+1,j), (i-1, j), (i, j+1) with weight of a[i]j]; Edited by author 19.02.2022 12:12 Why I get WA?! Edited by author 19.02.2022 12:12 Edited by author 19.02.2022 12:13 |
| Huuh! I've AC! | PSV | 1223. Chernobyl’ Eagle on a Roof | 19 Feb 2022 11:50 | 4 |
First DP formula like 1 + min max (a[i - 1, k-1], a[n - i,k ]) is NOT GOOD! In pascal it gets TLE! Take more clever formula!!! You can simply optimize this formula, assuming that min and max are convex functions. or binary search the intersection of (e eggs, f-th floor) #define T1(i) c[e][(i)-1] #define T2(i) c[e-1][f-(i)] |
| WA in 10 test, what is this test? | RadmirKhaniev | 1554. Multiplicative Functions | 18 Feb 2022 20:15 | 1 |
I hope that all tests take into account the multiplicative function condition: F(1) == G(1) == 1 |
| wrong answer, please help | TyumenIU_ubiyzza | 1196. History Exam | 18 Feb 2022 18:52 | 1 |
what are mistakes in this code? #include <iostream> using namespace std; long long int a[15000]; long long int b[1000000]; int main() { int c, f, d, e, g,l; l = 0; cin >> c; for (f = 0; f != c; f++) { cin >> a[f]; } cin >> d; for (e = 0; e != d; e++) { cin >> b[e]; } for (e = 0; e != d; e++) { g = b[e]; for (f = 0; f != c; f++) { if (g == a[f]) { l = l++; break; }
} } cout << l << endl; system("pause"); return 0; } Edited by author 18.02.2022 18:53 |
| Good problem! | Felix_Mate | 1752. Tree 2 | 18 Feb 2022 01:07 | 5 |
I got AC with O(N*sqrt(N)),but my solution is very hard(274 lines and many different subtasks). Who can say simple solution(idea without code)? Hi. This is my solution for this problem. Let's find two farthest nodes in tree. Let's call it f1 and f2. It can be done by two bfs'. Now let's answer for queries. Let the y farthest node from x(it's f1 or f2). If such node exists that dist(x, z) = d, then it would lie on path from x to y. If dist(x, y) < d, answer would be 0. Let l be lca(x, y). If dist(l, x) <= d, answer would be dist(l, x)'th parent of x. If x is ancestor of y, answer would be (dist(x, y) - d)'th parent of y. Otherwise answer would be dist(l, y) - (d - dist(l, x)). Sorry for my poor English. O(N*log(N)), ~100 lines of code, ~1K gzipped For every edge out of a node we calculate L, the length of the longest path from this node thru the edge. It is two DFS: the first one to calculate L for downward edges, the second one to fix the upward edges. At most two edges (with the largest L) of each node are needed to calculate the longest paths (the second is needed for the situations where we get from node A into node B and in node B the edge B->A has the maximal L). For these two edges we precalculate short-cuts: for all i, such that 2^i ≤ L, we save the node C that can be reached after 2^i steps and from which edge in C it was reached. My solution is quite simple, just find one farthest nodes pair in the tree by two DFSs, denoting f1 and f2. Then use f1 as root and dfs to calculate the 2^i steps' father of every node x. And use f2 as root similarly. Then the answer can be done by express d to the binary form and jump at most log(n) to find an answer under these two roots. We can actually solve it on just O(N) time. Let's set vertex 1 as a root. Now let's at first find the depths of subtree of each vertex, deepest vertex in each subtree and the distance from the root for each vertex. This can be done in one DFS. Let's name them as: 1) depth[ver] -> depth of a subtree of vertex ver 2) dist[ver] -> distance from vertex 1 to vertex ver 3) mx_ver[ver] -> deepest vertex in a subtree of vertex ver Now we can check for all queries: 1) If query is (v, d) and depth of vertex v is >= d, then the answer is the parent of vertex mx_ver[v] on distance (depth[v] - d) (so we should somehow later go up from vertex v to (depth[v] - d) edges). Let's store it in mx_ver[v]. 2) If query is (v, d) and distance from root to v >= d (so dst[v] >= d), then the answer is the parent of vertex v on distance d, let's store this information in vertex v. What should we do with all the other queries? All other queries (v, d) tell us that the answer for them will look somehow like this: Take vertex v, go up several edges, then go down to some other subtree. So we need to take some ancestor of v and go into it to a subtree different from a subtree containing vertex v. Let's say that this ancestor is some vertex u and the depth of its deepest subtree not containing v is H. Then if (dst[v] - dst[u] + H) >= d, we can choose u as a suitable ancestor. And the answer for the query will be the parent of the deepest vertex in subtree H on distance d - (dst[v] - dst[u] + H). Great thing about these formulas is that if we stay in some vertex v during some DFS, for all our ancestors the number (H - dst[u]) is a constant and we can keep the maximum value of it on current path. So what should we do next? Let's simply run one more DFS. During our walk through the tree in the DFS let's keep maximum value of (H - dst[u]) for all our ancestors. To do this we need to do some routine stuff: 1) Calculate two maximums by depth[to] + 1 for all children (if we will go to the subtree with first maximum, we will use H - dst from the second one). 2) Before going into some child check if the new found values are larger then global maximum (H - dst[u]). 3) Not forget to carefully restore this global maximum going up on each step. 4) Each time we take new maximum for (H - dst[u]), also store the deepest vertex in the subtree H. Then in each vertex during this DFS we also need to iterate through all remaining queries for this vertex and try to set an answer to them, again in form "Answer for this query is a parent of some deepest vertex in some subtree H on distance (dst[v] + (H - dst[u])) - d" The final step would be to run one more DFS and in all vertices with stored info "go up to distance X" do this by simply storing current DFS path and writing needed parent as an answer for the corresponding query. |