| Show all threads Hide all threads Show all messages Hide all messages |
| Получил АС, но время 0.7 | Felix_Mate | 1152. False Mirrors | 3 Aug 2015 15:50 | 1 |
Я решил стандартно с помощью маски: Dp[mask], где mask - очередное состояние. Рассмотрел все переходы с потерями и выбрал минимальный из них. Асимптотика O(N*2^N). Как решить эффективней (кроме оптимизации в переходах,т.е. не рассматривать,скажем три нуля подряд в маске) не знаю. Может,кто-нибудь даст идею,как кроме стандартной лобовой маски решить? |
| Why two equal Java codes give different results? (test #13) | Ivan Avdonin (Vologda ML) | 1820. Ural Steaks | 3 Aug 2015 07:09 | 1 |
First code gives wrong answer test #13. In the next code I changed System.out.print(2*n/k+2*n%k); and used Math.ceil() System.out.print((int)Math.ceil(2*(float)n/(float)k)); The code was accepted. What's wrong? Edited by author 03.08.2015 07:16 Edited by author 03.08.2015 07:17 Edited by author 03.08.2015 07:17 Edited by author 03.08.2015 07:17 Edited by author 03.08.2015 07:18 Edited by author 03.08.2015 07:18 Edited by author 03.08.2015 07:22 |
| If you're using BFS :D | GastonFontenla | 1930. Ivan's Car | 2 Aug 2015 15:05 | 1 |
If you are using BFS, use a adjacency list. It's faster for finding the adjacents nodes. You too should use a "direccion list". It has the same size that the adjacency list, but it's filled with boolean values. For example, in the adjacency list of the node 1, you have nodes 2 3 4. If you need to go uphill from 1 to 2, in the correspondant place of the 2, you should write a 1, and if you need to go downhill, a 0. This is how I solved. I was stuck on time limit when I was using the same format of given data, but later I understood that the adjacency list it's very faster than 2 cols matrix (faster, but uses a lot more memory). Good luck, and try all the test posted in discussion. |
| some test | ProgBeat | 1158. Censored! | 31 Jul 2015 22:46 | 3 |
2 5 3 01 0 11 10001 ans: 0 Edited by author 26.06.2007 18:43 OH it's a good test. i'm writing DFA th e first time, and i don't know what's wrong with my program. this test helped me. Thank you very much! This test really helped me. |
| I'm confused with the statement | Mickkie | 1840. Victim of Advertising | 31 Jul 2015 14:14 | 2 |
Each of the cameramen wants Lev to skate along a segment of a straight line from some point to another (and each has specified his own pair of points). Lev has decided to skate along all the specified segments passing from a segment to a segment along a circular arc so that his trajectory has the shape of a smooth curve. Do Lev move in a circular arc or a straight line? If there is no arc connecting two consecutive directed segments without breaks, Lev can extend one of the segments so as to connect them by an arc. For example 2, do these circles valid to this statement? (-1,-1) radius = sqrt(26) (1,1) radius = 3*sqrt(2) (0,0) radius = 2*sqrt(5) but (-2,-2) radius = 6 is invalid because the endpoint of the segment doesn't end in this circle. Am I right? And Finally how do you compute 7.1415926536? because I find that circle (-1,-1) could yield better solution for about 6.69659557624 None of these circles are valid because you should construct a SMOOTH curve, containing ALL the segments described in the test (and also don't forget about their direction). The only valid circle is (0,0) radius = 4. And Lev can't move on it faster than sqrt(4) = 2. That's why we have such answer. |
| Any Help in Runtime error (access violation) test #13 | Maged Milad | 1471. Distance in the Tree | 30 Jul 2015 20:24 | 2 |
If anyone know hint or test case for test#13 I used RMQ and LCA to solve this Problem |
| wa19 | Roman | 1643. Attack of the Dark Fortress | 30 Jul 2015 20:02 | 5 |
wa19 Roman 28 Oct 2008 23:30 Re: wa19 Hanzbrow (TNU) KCC 12 Jul 2009 18:09 I had the same WA19. This test helped me figure out the issue 10 10 ......#!#. ......##Z. ...Z...... ...Z*..... ...ZKK.... ......##.. .....K.##. .....##$#. ......###. .......... correct answer is 3, but my old code generated 4 my code gives 3, but I still got WA#19 Thank you very much! This test helped me when I had problems with test 11. |
| Samplz input | watashi | 1783. Nuclear Arms Race | 30 Jul 2015 16:42 | 3 |
Can anyone explain me how we got the sample input ? why "2 1 1 -2", or "2 1 1 0" is not an answer ? I have the same question. Can someone please aws? Thanks! If the fourth order of Western Cuckooland dictator was '-2', then the number of warheads by the end of 4th month would have been 2, 5th — 0, that is less than in Eastern Cuckooland. The answer is not '0' because it is not the minimal value. Order '-1' is OK. Maybe you should try drawing imaginary lines that will show you how much warheads there will be in Eastern Cuckooland according to every order of its leader to understand how we get the sample. Edited by author 30.07.2015 16:46 |
| Fail(checker) | White2302(Vologda ML) | 1677. Monkey at the Keyboard | 30 Jul 2015 16:15 | 1 |
when i submit i have fail(checker). What can I do with that? |
| My stupid WA11 | Mickkie | 1357. Teakettle 1.0 for Dummies | 29 Jul 2015 21:37 | 1 |
if the "ss" answer equal 60, update to 0 and change mm = mm+1 :) |
| Hint: AC in Python 2.7 | SRC | 1133. Fibonacci Sequence | 29 Jul 2015 15:41 | 1 |
The fastest way is to use matrix exponentiation and it is quite simple to understand. The algorithm is O(log n), yes it is that fast!. I got AC with Python 2.7 with 0.046s. Python has an added advantage for this problem since its Integer type can be as big as the RAM of the device being used. With c++ you can still get answers fast, using matrix exponentiation, but the answers are not precise enough, and leads to WA. Edited by author 29.07.2015 15:42 |
| care about -0.0 | eycia | 1942. Attack at the Orbit | 29 Jul 2015 14:22 | 1 |
|
| Crash (access violation) on test 1 | Abzal | 1471. Distance in the Tree | 28 Jul 2015 23:44 | 3 |
plz, help me! why i get crash(access violation). // LCA (least common ancestor) offline by using interval tree in O(logN) // Solution by Serekov Abzal #pragma comment(linker, "/STACK:16777216") #include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <cmath> #include <map> #include <set> #include <queue> using namespace std; int ADD = 65536; int inf = 9999999; vector <vector <pair<int, int> > > graph; vector <bool> b(50001, false); vector <int> h(50001, 0); vector <int> order; vector <int> d(50001, 0); vector <int> first(50001, -1); pair <int, int> tree[2 * 65536 + 1]; int n, root = 0; void init_graph() { scanf("%d", &n); graph.resize(n); for (int i = 0; i < n - 1; i++) { int u, v, w; scanf("%d%d%d", &u, &v, &w); graph[u].push_back(make_pair(v, w)); graph[v].push_back(make_pair(u, w)); } }; void dfs(int v, int p) { b[v] = true; h[v] = p; order.push_back(v); for (int i = 0; i < graph[v].size(); i++) if (!b[graph[v][i].first]) { dfs(graph[v][i].first, p + 1); order.push_back(v); } }; void bfs(int v) { queue <int> Q; Q.push(v); while (!Q.empty()) { int u = Q.front(); b[u] = true; for (int i = 0; i < graph[u].size(); i++) if (!b[graph[u][i].first]) { d[graph[u][i].first] = d[u] + graph[u][i].second; Q.push(graph[u][i].first); } Q.pop(); } }; void prepare() { h[root] = 0; dfs(root, 0); for (int i = 0; i < order.size(); i++) if (first[order[i]] == -1) first[order[i]] = i; for (int i = 0; i < n; i++) b[i] = false; d[root] = 0; bfs(root); }; int minimum(int u, int v) { int l = u, r = v, ans = inf, ver = inf; while (l <= r) { if (l % 2 == 1) { if (tree[l].second < ans) { ans = tree[l].second; ver = tree[l].first; } l++; }; if (r % 2 == 0) { if (tree[r].second < ans) { ans = tree[r].second; ver = tree[r].first; } --r; } l/=2; r/=2; } return ver; }; int lca(int u, int v) { int l = first[u] + ADD, r = first[v] + ADD; return minimum(l, r); }; void init_zaprosi() { int m; scanf("%d", &m); for (int i = 0; i < m; i++) { int u, v; scanf("%d%d", &u, &v); int ans = d[u] + d[v] - 2 * d[lca(u, v)]; printf("%d\n", ans); } }; void tree_build() { for (int i = 0; i <= 2 * ADD; i++) tree[i] = make_pair(-1, inf);
for (int i = ADD; i < ADD + order.size(); i++) { tree[i].first = order[i - ADD]; tree[i].second = h[order[i - ADD]]; } for (int i = ADD - 1; i > 0; i--) { if (tree[2 * i].first == -1 || tree[2 * i + 1].first == -1) { if (!(tree[2 * i].first == -1 && tree[2 * i + 1].first == -1)) { if (tree[2 * i].first == -1) tree[i] = tree[2 * i + 1]; else tree[i] = tree[2 * i]; } } else { if (tree[2 * i].second < tree[2 * i + 1].second) tree[i] = tree[2 * i]; else tree[i] = tree[2 * i + 1]; } } }; int main() { init_graph(); prepare(); tree_build(); init_zaprosi(); return 0; } I've just resized size of segment tree to 2 * 131072, and one thing: not everytime u < v, there can be like u > v, so i swaped them, and i got AC So, everyone assumed 0 is the root of the tree. I don't find it in the problem description. |
| Hint | Frankey | 1709. Penguin-Avia | 28 Jul 2015 17:56 | 4 |
Hint Frankey 26 Jul 2009 21:25 This is very easy problem. You can use: 1) BFS or DFS to find the components of the graph; 2) Prim or Kruskal algo for minimum spanning tree. spanning tree can be built during BFS. It's correct because graph is unweighted. Re: Hint Artem Khizha [DNU] 16 Jul 2011 17:22 Well, I see, that this is MST problem, but cannot get how to build a graph for it. Please, explain your step 1 more precisely. Re: Hint Sehriyar Novruzov 28 Jul 2015 17:56 Sure, it can be solved applying BFS or DFS + Minimum Spanning Tree algorithms (Prim Algorithm). But, BFS or DFS is enough to solve it. BFS or DFS is implemented to identify Connected Component and Non-Connected Component. No need to apply MST to remove redundant edges in each Connected Component. Because, while BFS or DFS you can built identify which edges you need and don't need. Here is one part of my code to do BFS and work like Prim algo [code deleted] Edited by moderator 19.10.2019 20:33 |
| Test 6 Runtime error | Sergii Kovach | 1123. Salary | 28 Jul 2015 14:35 | 1 |
Can you be more explicit about the error? I used lots of test cases from discussions and code show's correct results without errors. Do you need me to post my solution? Edited by author 29.07.2015 13:55 |
| WA | shouu | 1196. History Exam | 28 Jul 2015 07:37 | 1 |
WA shouu 28 Jul 2015 07:37 给二分查找的参数传错了,传的是m。 弄得我都快崩溃了。 不过还好看了解答发现了。 下面是C代码 ********************************************************************************************** #include<stdio.h> int teacher[15001]={0}; int exist_temp(int temp,int m){ int first=0,last=m-1,count=0; while(first<=last){ int mid=(first+last)/2; if(teacher[mid]==temp){ count++; return count; } else{ if(teacher[mid]>temp) last=mid-1; else first=mid+1; } } return count; } int main(){ int n,m,i; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d",&teacher[i]); scanf("%d",&m); int count=0,hi=m; while(hi--){ int temp; scanf("%d",&temp); if(exist_temp(temp,n)!=0) count++; } printf("%d\n",count); return 0; } |
| WA12 | MOPDOBOPOT (USU) | 1871. Seismic Waves | 27 Jul 2015 22:51 | 2 |
WA12 MOPDOBOPOT (USU) 15 Nov 2011 23:17 I'm using dfs and can't find test for my program :( Edited by author 02.08.2012 16:46 Re: WA12 MOPDOBOPOT (USU) 27 Jul 2015 22:51 Now got AC by carefully modeling twitting process. |
| Is a root node for the tree? | aigoruan | 1471. Distance in the Tree | 27 Jul 2015 21:58 | 3 |
Is a root node for the tree? You mean 0 is the root of the tree? |
| Have you any tricks how to solve? | SkorKNURE | 1474. About Frogs | 27 Jul 2015 10:45 | 4 |
>No, just bruteforce... A little optimized bruteforce gave me TLE in 'n' < ~20 There is a simple pattern in frogs moving. Paper simulation is so bored pastime - I had found out the pattern when wrote simple bruteforce for small 'n' cases. GL :) I found a pattern on the movemente... move first black frog Then: move first & second white frog then: move first & second & third black frog keep doing this until the end while doing that: always start for the first frog that hasn't arrive to their final position always end if you don't have anymore frogs to move example with 2 and 3 8 1 3 4 2 0 1 3 2 15 2 4 5 3 1 0 2 4 6 5 3 1 2 4 3 Good luck |
| test case answer | rakeshvarna | 1269. Obscene Words Filter | 26 Jul 2015 22:27 | 2 |
can somebody explain how the example shown has answer as 6 33 and not 6 44? are we not supposed to give the word position? 33 is number of symbol position in line)) Edited by author 26.07.2015 22:28 Edited by author 26.07.2015 22:28 |