Show all threads Hide all threads Show all messages Hide all messages |
Test for WA#8 | Xaker MSU_Tashkent | 1014. Product of Digits | 24 Nov 2012 23:50 | 3 |
But 26 is less than 34 Edited by author 24.11.2012 23:51 |
Help me 'Crash (stack overflow)' | hhiepit | 1586. Threeprime Numbers | 24 Nov 2012 17:29 | 1 |
My solutions is stack overflow in test 9. Help me, please. |
Hlep-WA Test6 | moonshang | 1002. Phone Numbers | 23 Nov 2012 22:05 | 1 |
Could anyone give me the test#6? godsuriyel@gmail.com thanks! |
what's test2 ? | SODIQJOHN | 1917. Titan Ruins: Deadly Accuracy | 23 Nov 2012 21:36 | 8 |
It helped me: 5 4 2 2 1 1 1 answer: 5 2 EDITED - NEVER mind - I think I understand Edited by author 07.11.2012 09:58 Edited by author 07.11.2012 09:58 Becase 1 spell of strength 2 eliminates 3 coins (1, 1, 2) The (4,4) can never be eliminated because it causes a bounce back of 8, and 7 is the survival limit |
Need help wa#2 | Pegasus | 1917. Titan Ruins: Deadly Accuracy | 23 Nov 2012 21:02 | 1 |
I want some tips or tests |
No subject | 2chik | 1114. Boxes | 23 Nov 2012 19:41 | 1 |
var i,s3,s4,s,s1,s2,n,a,b:Longint; begin read(n,a,b); s:=1; s1:=1; s2:=1; s3:=1; s4:=1; for i:=1 to n+a do s:=s*i; for i:=1 to n+b do s1:=s1*i; for i:=1 to n do s2:=s2*i; for i:=1 to a do s3:=s3*i; for i:=1 to b do s4:=s4*i; write((s*s1)/(s2*s3*s4*s2)); end. |
what is the test #5? How was I wrong at it? | yang | 1869. New Year Cruise | 23 Nov 2012 18:14 | 3 |
My solution is that 1. I calulate how many passengers go off when the train arrive the station i , called Di[i] (assume we are doing on the first turn that is from Vladivostok to Moscow). And I also have similar manipulation on doing the second turn that is from Moscow to Vladivostok), called Ve[i] 2. Then, I do for (i = 2; i <= n; i++) to browse all stations that the train will come. At station i, I subtract the number of passengers who go off the train at the station (i - 1) and plus the number of passengers who will come to the station i. And, I find the MAX from them at every station i, called luotDi. I do the same with the second turn from Moscow to Vladi..., called luotVe 4. I find maxPassengers = max(luotDi, luotVe) 5. I print the result (how many cars) = maxPassengers / 36 + 1 * (maxPassengers % 36 == 0 ? 0 : 1) I can't find what I was wrong. Please help me! Here my source code #include <iostream> using namespace std; int main() { int n; int tam; int a[106][106]; int Di[106]; int Ve[106];
int luotDi = 0; int luotVe = 0; cin >> n; for (int i = 0; i <= n + 5; i++) { Di[i] = Ve[i] = 0; }
for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cin >> a[i][j]; if (i < j) { Di[j] += a[i][j]; } else { if (i > j) Ve[j] += a[i][j]; } } }
// the first turn (Vla... -> Moscow) int soKhach = 0; // station j th for (int j = 2; j <= n; j++) { // drop passengers soKhach -= Di[j - 1];
// pick up passengers for (int i = 1; i < j; i++) { soKhach += a[i][j]; }
// find MAX if (soKhach > luotDi) { luotDi = soKhach; } }
// the second turn (Moscow -> Vla...) soKhach = 0; // station j th for (int j = n - 1; j >= 1; j--) { // drop passenger soKhach -= Ve[j + 1]; // pick up passenger for (int i = n; i > j; i--) { soKhach += a[i][j]; } // find MAX if (soKhach > luotVe) { luotVe = soKhach; } }
int result; float lDi = (float) luotDi; float lVe = (float) luotVe; if (luotDi > luotVe) { lDi = lDi / 36; result = (int) lDi; if (result < lDi) { result++; } } else { lVe = lVe / 36; result = (int) lVe; if (result < lVe) { result++; } }
cout << result; return 0; } Thanks very much! Edited by author 15.10.2011 17:52 The way you calculate drop and pick up passengers is wrong :(. Edited by author 16.10.2011 12:29 Edited by author 23.11.2012 18:15 |
I do not understand an sample. help, please | alp | 1162. Currency Exchange | 23 Nov 2012 16:21 | 4 |
how Andrey will increase the capital? 2: (20-1)*1 =19 3: (19-1)*1=18 **** How can more, than 20? thank I understood,...:) Edited by author 18.02.2017 01:54 I'm too... Please, somebody explane sample. Why I can only increase money: 1->2 (20-1)*1=19 2->3 (19-1)*1.1=19.8 3->2 (19.8-1)*1.1=20.68 2->1 (20.68-1)*1=19.68 Where I mistake. Or Nick can just do all day 2->3 3->2 2->3 3->2 ........ ........ 2->3 3->2 and when he will have INF money, he exchange currency from 2 on 1. =) Edited by author 10.10.2012 03:56 just ignore the words "Let us call some sequence of the exchange operations simple if no exchange point is used more than once in this sequence." it's sample spfa |
regarding input taking | annonynous | 1001. Reverse Root | 23 Nov 2012 15:23 | 2 |
unable to understand do we have to read input from file or user i mean how many numbers are taken as input. as in sample four numbers are given plz help Edited by author 23.11.2012 09:56 Edited by author 23.11.2012 09:56 This problem is a little different from the others in terms of input. You're not told ahead of time how many numbers there are, but you are told the input will not exceed a certain number of bytes (the byte limit info which you don't have to use if you don't want to). You read from standard input, like all other problems, until there is no more input. E.g., "while not end of file, read the next number..." |
Test 3 | Alexander Goncharov | 1269. Obscene Words Filter | 23 Nov 2012 13:28 | 1 |
Test 3 Alexander Goncharov 23 Nov 2012 13:28 I use Aho Corasick algorithm but get "Wrong answer 3". Why? Please give me test 3. Edited by author 23.11.2012 13:28 |
DO LIKE ME Accepted HE MY PROGRAM memory 17 byte | Oleg | 1135. Recruits | 23 Nov 2012 11:06 | 5 |
var i,n,L,R:longint; ch:char; begin readln(n); L:=0; R:=0; for i:=1 to n do begin read(ch); while not(ch in ['<','>']) do read(ch); case ch of '>':inc(R); '<':inc(L,R); end; end; writeln(L); end. Denote by R the number of recruits at the right end of the queue. When you get a new '>', simply increase R by 1. If you receive a '<', the process is like this: >>>>>< (Say R=5) >>>><> >>><>> >><>>> ><>>>> <>>>>> Now you see, it takes exactly R turns to send the '<' to the left of the '>'s, and the number of the '>'s, or R, stays the same. So it's easy to understand the prog. 10 >>>><>>>< What about this test? |
TLE(c++)? | mah1991 | 1135. Recruits | 23 Nov 2012 09:29 | 3 |
why do i get Time limit exceeded :( #include <cstring> #include <cstdlib> #include <cstdio> using namespace std; int main () { char * pch; char str[30005],str1[30005]; int number,i=0,j=0; scanf("%d",&number); while(i<number) { scanf("%s",str); i+=strlen(str); strcat(str1,str); } while(strstr(str1,"><")) { pch=strstr(str1,"><"); strncpy(pch,"<>",2); j++; } printf("%d",j); return 0; } I used very similar code and got AC (though there is a better solution if I recall correctly). What I did is: - If you have <<< at left end or >>> at right and, you can ignore those - they will never change again. Thus, you can keep treack of the left and right endings, and only parse those, instead of going from 0 to n every time. AC 0.625 #include <iostream> using namespace std; int main() { int n; cin >> n; char c; int t = 0, ans = 0; while (n--) { cin >> c; if (c == '>') ++t; else ans += t; } cout << ans << endl; return 0; } |
Russian version of statement | Yermak | 1655. Somali Pirates | 23 Nov 2012 08:57 | 1 |
Эпиграф: следует писать "филиппинцы". Последнее предложение первого абзаца: "иначе пушку уже нельзя будет навести на цель, и команда попадет в плен" - запятая не нужна. |
please provide me some tests | luckysundog | 1002. Phone Numbers | 22 Nov 2012 23:11 | 6 |
WA4, i still don't know why :) please give me some cool inputs and (optionally) your answers to them. 1234567890 10 jafgl n ehlnr tyz ru ja iad jadh pty yo ans:ja ehlnr tyz thank you, i've already found mistakes. now optimizing memory strategy... the test that tiancaihb give has two possibile solutions: ja ehlnr tyz jafgl n ru yo the first one is shorter so it work fine in my program but I stil get WA4 and do not know where to look for mistake. Can someone give me any tip in what cases it work wrong. Another test. Mainly to check TLE: 2222223222222222322222 etc. 5 a aa afa aaaa aafaa Answer - aaaa aafaa aaaa aa afa aaaa Answer - aaaa aafaa aaaa aa afa aaaa Answer - aaaa aafaa aa aaaa afa aaaa |
for admin | BoburSh | 1014. Product of Digits | 22 Nov 2012 22:51 | 2 |
To whom it may concern! There were sovlved two different programms. The first one, when there is given an input 120 the output is 358; the second output is 456. But both of them were accepted. Could you explain to me why this that, if you please? It's because of weak tests :D |
What should I do if N is odd? What's the first 'half' and the second 'half' in this case? | Maigo Akisame (maigoakisame@yahoo.com.cn) | 1289. One Way Ticket | 22 Nov 2012 13:00 | 5 |
|
What does "number system" means ? What is the limit of it ? | Tran Nam Trung (trungduck@yahoo.com) | 1071. Nikifor 2 | 22 Nov 2012 12:31 | 6 |
Can anybody tell me what exactly "number system" means? I can't understand what TNT and DQH talking about. maximal number system base is not more than 1 million. |
There is algo in O(n). Try to find it ;) (-) | Tbilisi SU: Andrew Lutsenko | 1510. Order | 22 Nov 2012 04:55 | 21 |
My algo is exactly O(n). Constant is 1. Just reading input, sometimes even not the whole input. What is K in your formula? I have O(N) solution, AC (0.156). I use "bucketing". But there is solution that works two times faster :( I think for this problem O(n) algorithms as many as stars in the sky. For example 1) qsort; 2) moving along and counting copies of equal values. I have O(N) solution, AC (0.156). I use "bucketing". But there is solution that works two times faster :( In this problem I/O hacks gave me much more speedup than algorithmic issues. My 0.078s solution uses the same linear time, constant memory algorithm as the 0.546s one. 0.062 :P just use your own procedure for reading numbers instead of fscanf. It must read numbers char-by-char Edited by author 31.10.2006 02:17 My solution uses random function and got AC! lol Hehe. I think there are no tests like this: 11 1 2 1 2 1 2 1 2 1 2 1 or you are very lucky =) My program have AC(0.046) too. But I use only 96kB memory:-) Edited by author 08.03.2007 17:51 Bucketing assumes that we keep an array as big as the value range, which is one billion in this problem. So I suppose you talk about per-digit bucketing, but it is still O(N*log(K)) if we treat input numbers regardless of their base-10 representation. Did you get that constant because of limited length of particular number, given limit on its value? Just telling that it is O(N) just becase representation is fixed to base-10 is not quite far from telling that it is O(1) becase N itself is limited by 500'000 - a constant :) Edited by author 13.07.2008 20:45 Edited by author 13.07.2008 20:45 The O(n) algorithm is Boyer-Moore Majority Vote Algorithm, which time is linear, and memory constant... in fact you don't need more than 3 integer variables to run this algorithm... As some people have mentioned, writing your own int input procedure may improve your performance a lot. First time with no optimization i got 1.06s, then i used a getc() based int input procedure and did some little changes in the code and got 0.046s :) One more O(N) algo is K-th ordered statistics, which is explained in Kormen et. al. So, will program, which reads number and increases the variable, which counts how many times did we meet that number get AC, but not TLE? Thank you for this great suggestion! How did you guys optimize I/O ? Can send me your I/O procedure, my email : tungnk1993@gmail.com i tryed many different ways but always got tle on 19 or 20 tests .Than i saw Boyer-Moore Majority Vote Algorithm.it's really good algo for this problem .Here is algo http://www.cs.utexas.edu/~moore/best-ideas/mjrty/index.html. here is'n written than number of majority element must be more than half so i thought that it would write right answer in any case for example in that case B B B B A A A A A C C C but no .in that algo it's very important the number of majority element to be more than (n/2) thanks . Sorry for bad English. Edited by author 17.01.2012 14:52Boyer-Moore is one of those "brilliant in its simplicity" types of algorithms. Beautiful! |
Crash (access violation) !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | Momchil Tomov | 1106. Two Teams | 22 Nov 2012 03:47 | 4 |
on test # 1...................... if i get it again, i'm gonna break something.... it runs perfectly on my compiler #include <stdio.h> #include <iostream> #include <vector> #define PB push_back using namespace std; int lev[110]; int main() { int i,j,k,l,n,s,e,v; int q[10100]; vector<int> a[110]; scanf("%d",&n); // cin>>n; for (i=1; i<=n; i++) { while (1) { scanf("%d",&j); // cin>>j; if (j!=0) a[i].PB(j); else break; } } for (i=1; i<=n; i++) if (!lev[i]) { q[0]=i; e=0; for (s=0; s<=e; s++) { for (j=0; j<a[q[s]].size(); j++) { v=a[q[s]][j]; lev[v]=lev[q[s]]+1; q[e++]=v; } } } vector<int> ans; for (i=1; i<=n; i++) if (lev[i]%2) ans.PB(i); printf("%d\n",ans.size()); for (i=0;i<ans.size()-1; i++) printf("%d ",ans[i]); printf("%d\n",ans[ans.size()-1]); return 0; } 2 0 0 Every member has one or more friends in the group!!! > Every member has one or more friends in the group!!! The problem statement does not say this. It says that friendship is mutual (the friendship must exist for this to be true), and that the friendship list is terminated by a 0. So it is allowed for a member to have no friends. |
WA2 C++ | Pavel | 1197. Lonesome Knight | 22 Nov 2012 00:09 | 1 |
It was really wrong :) Edited by author 22.11.2012 11:33 |