Common BoardWhy? I had the same problem and my mistake was treating n as always a power of 2, thus doing some extra work in the last step. Revise your code for that. Hope this helps. Please help, I feel that I got the correct idea. Just think about it. In the example there are three steaks, and only two can be cooked at the same time. It would take two minutes to cook both sides of the first pair and another two to prepare the last steak. In total it makes four. I'm just curious, did the author mistype or is there an actual mistake in the program. Sample is correct, find the mistake in your logic. I've tried a solution usind a matching algorithm and my answer is match + every_node that is not part of the match and I have WA. Can someone explain me how to do this problem? LE: I got it! Never mind! Edited by author 09.09.2013 21:06 6 10 ababaabaab ababbbbbbb baaaaababb bbaaabbaba bbbbabbabb abbbaaaaaa answer: 14 Good luck! Совсем не могу понять почему не проходит 6 тест, проблема у меня не 59,9 как было у другого задовавшего вопрос... lual.ru Edited by author 08.09.2013 18:45 #include <stdio.h> #define c 65535 int main() { long long k = 0; long long a[c]; long n = 0,i,ot[c],j,t;
a[0]=1; for (i=1; i<=c; i++) { a[i]=a[i-1]+i; } scanf("%ld",&n); for (i=0; i<n; i++) { scanf("%lld",&k); for (j=0; j<c; j++) { t=0; if (a[j]==k) { t=1; break; } } ot[i]=t;
} for (i=0; i<n; i++) { printf("%ld ",ot[i]); } return 0;
} That's how I get AC after so much time. Edited by author 06.09.2013 22:11 For solving this problem I used advanced bipartite graph theory. But it work slowly(about 0.6sec). Very interesting how solve more quickly. Please, give me some hints.(My e-mail: scarlet.flower@list.ru) Maximum matchings in bipartite graph is almost enough to solve it + some "magic" :) Maybe maximum flow algos' works better here... My complexity was O(V*E), 0.3sec Just gredy. Also, O(NlogN) solution exists On my VS 2012 C# compiler on test 1000 1000 1000 my program's output is 0.0000143861 288.6751345948 which doesn't seem to fit into precision (from the solution correctness criteria). But AC on timus under VS 2010 C# compiler. Just interesting: there is no such test, timus VS 2010 is better than my VS 2012, or checker checks not equality of both numbers in output and answer, but some more weird thing? There was incorrect checker, it checked with precision 10^-4. It fixed now, all solutions were rejudged, 7 authors lost their AC. I think I found counter example for this, ie. set of points of which one is inside the 3D convex hull, but it's appropriate contenstant can win. If we are given for contestant with following speeds: 1 1 2 1 1 4 100 1 3 1 100 3 20 20 3 If we choose paths of length 100, 100, 3, than last contestant (20, 20, 3) can win with time 100/20 + 100/20 + 3/3 = 11. But, for this points 3D convex hull consists of (1, 1, 2), (1, 1, 4), (100, 1, 3) and (1, 100, 3). Does anyone know if I'm wrong and why? Consider that the sum of swim,bike and run is a const number,so we can let the total s=1,then we can solve it for 2D convex hull alogrithm rather than 3D. You should use reciprocals of speeds (preferably multiplied by some constant) as coordinates, but not just the speeds. After applying such an "inversion" to the points in your example, the last one jumps out of the convex hull formed by others. why wa #7 please help( #include <stdio.h> int main(void) { int s; int p; float zo; int t = 0; scanf("%f",&zo); scanf("%d",&s); scanf("%d",&p); while(zo>s){ zo -= zo*p/100; ++t; } printf("%d",t);
return 0; } use float instead of int for s and you will get AC It's the first test where more than one memory cell needs to be modified. Do I miss something in the problem statement? E.g. is this test correct? azkazkazkazkazkazkazoazv ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++.+++++++++++++++++++++++++.<+++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>>+++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++.<.<.>>.<.<.>>.<.<.>>.<.<.>>.<.<.>>.<.<++++.>>.<.----. Try this test: azqhazqhazqhazqhazqhazqhazqhazqhazqhazqhazqhazqh My answer: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++.<+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.<++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.<+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.>>>.<.<.<.>>>.<.<.<.>>>.<.<.<.>>>.<.<.<.>>>.<.<.<.>>>.<.<.<.>>>.<.<.<.>>>.<.<.<.>>>.<.<.<.>>>.<.<.<.>>>.<.<. Observe than A[i] must be equal 0 or 1 ( no double ). Just compute dp[v]. dp[v] is cost of traffic of subTree with root v if A[v] = 1. If A[v]=0 than cost(of traffic of subTree with root v) equals zero. Edited by author 03.09.2013 01:58 Edited by author 03.09.2013 01:59 Test: 2 1 2 answer: 1 Maybe your answer is 2? =) Edited by author 02.09.2013 03:44 Edited by author 02.09.2013 03:46 My solution failed in test 30. How I can find what is wrong? Help me please Edited by author 01.09.2013 23:49 Give me please 3 (third) test. I've tested with other tests from this forum - all works fine, but I have WA#3 problem... I rewrote my solution - got time limit on 10th test - good, but I think it's may be bug (or feature?) in 3 test (because i changed only 1 feature in input/output code). Can anyone give me this (3) test? Edited by author 30.08.2011 06:23 Edited by author 30.08.2011 06:26 I will show you only two combinations("x" means stone, that was killed at last lead). 1). Those you can kill three stones oo xo oo ox oo oo ox o oo oo o o 2). Those you can kill six stones o oo ox o oooo ooox oox oo oo ox o oooo ooo oo oo xo oo ox This are all you need to get AC. (But I cannot prove that if (M Mod 3 = 0) or (N Mod 3 = 0) answer is 2, I can only show how make it) P.S. Sorry for bad English. BTW, you also need that if you have only one row or column, you can only take half of the stones Interesting. But I also can't proove it! How to get this idea more formally? Let's talk about this. Thank you if n or m is divided by 3 we can prove that we can leave only 3x3 stones. and than its easy to finish game with 2 stones. assume that m is divided by 3.so we can divide rectangle into m/3 parts and reduce each's "n" to 3. than reduce m to 3 and we'll get cube with dimensions 3x3. Edited by author 16.04.2007 22:24 I still can't get it,especially for your graph,I hope you can explain it more clear. Thanks. Here comes the proof of why you can't remove all stones but one if M or N is divisible by 3. Let us paint all the grid nodes for which the sum of their coordinates is divisible by 3 ((x + y) mod 3 = 0) in red, all ones meeting the (x + y) mod 3 = 1 condition in green, and the rest in blue. Let us also denote the amount of stones placed in red, green and blue nodes as R, G and B respectively. Obviously, each turn two stones lying on nodes of different colors turn into one stone lying on the third color. So, two of the R, G and B values get decreased by 1, and the third one gets increased by 1. This process has an invariant: parities of (R - G), (R - B) and (G - B) don't change! At the start of the game with M or N being divisible by 3 R, G and B are equal. So all the three differences listed above stay even till the very end, and it's impossible to get the (1,0,0), (0,1,0) and (0,0,1) combinations of R,G,B, therefore the game can't be finished with only one stone. Q.E.D. P.S. My English could have some flaws, i know. #include<stdio.h> #include<algorithm> #include<list> using namespace std; int main(){ char str[200000]; cin>>str; bool litter[26]; for(int i=0;i<26;i++) { litter[i]=false; } for(int i=0;i<strlen(str);i++) { litter[str[i]-'a']=!litter[str[i]-'a']; } list<char> clist; for(int i=0;i<strlen(str);i++) { if(litter[str[i]-'a']) { litter[str[i]-'a']=false; clist.push_back(str[i]); } } copy(clist.begin(),clist.end(),ostream_iterator<char>(cout)); return 0; } it do works on my own machine, How? |
|