| Show all threads Hide all threads Show all messages Hide all messages |
| WHY WA#16 | Nick Loginov (USU) | 1201. Which Day Is It? | 27 Feb 2011 17:16 | 2 |
WHY WA#16 Nick Loginov (USU) 26 Mar 2010 08:44 Try to check this: 25 11 1885. The right answer is: mon........2....9...16...23...30 tue........3...10...17...24 wed........4...11...18..[25] thu........5...12...19...26 fri........6...13...20...27 sat........7...14...21...28 sun...1....8...15...22...29 Edited by author 27.02.2011 17:19 |
| Any idea where the mistake is? | Pawel Wanat | 1010. Discrete Function | 26 Feb 2011 19:10 | 5 |
This code gets WA on test 2: [code deleted] & this gets AC: [code deleted] :) Edited by moderator 02.01.2020 18:26 Try to use scanf("%I64d", &tab[i]); Oh! It's like in dev :) thx for info. . The operating system may be windows, not linux, but why it return WA instead of CE? Edited by author 27.07.2009 20:46 Cause your solution is wrong. |
| Is there any O(1) solution? | Sergey Zuev | 1017. Staircases | 26 Feb 2011 18:54 | 3 |
I know O(n^2) one. Maybe there is also an O(1)? I have an O(n*logn) one...but surely not good enough... |
| what's wrong? | Samirson | 1197. Lonesome Knight | 26 Feb 2011 16:14 | 1 |
#include <stdio.h> int main(void) { int n,k,i; char c; scanf("%d",&n); while(n--){ scanf("%1s%d",&c,&k); if((c=='a'||c=='h')&&(k==1||k==8)) {printf("2\n"); continue;} if((c=='a'||c=='h')&&(k==2||k==7)) {printf("3\n"); continue;} if((c=='b'||c=='g')&&(k==1||k==8)) {printf("3\n"); continue;} if((c=='b'||c=='g')&&(k==2||k==7)) {printf("4\n"); continue;} if(c<'b'||c>'g') {printf("4\n"); continue;} if(k<2||k>7) {printf("4\n"); continue;} if((c=='b'||c=='g') || (k==2||k==7)) {printf("6\n"); continue;} printf("8\n"); } return 0; } |
| What's wrong with my C# code? It is giving wrong answer in case # 2... | Alaska . PK | 1423. String Tale | 26 Feb 2011 00:03 | 1 |
long stringLength = Convert.ToInt32(Console.ReadLine()); string S = Console.ReadLine(); string T = Console.ReadLine(); long temp = 0; bool check = false; for (long i = 0; i < stringLength; i++) { S = S[Convert.ToInt32(stringLength) - 1] + S.Substring(0, Convert.ToInt32(stringLength) - 1); if (S == T) { temp = i + 1; check = true; break; } } if (check && temp < stringLength) Console.WriteLine(temp); else Console.WriteLine(-1);
|
| Note to the solution of the test number 3 | Alflex | 1294. Mars Satellites | 25 Feb 2011 21:49 | 1 |
The printing of the answer in C++ should be, e.g., in the form: cout << "Distance is " << setiosflags(std::ios_base::fixed) << setprecision(0) << 1000.0*sqrt(dist) << " km."; where dist is double value. You don't need to round off the answer with the help of some functions. |
| Test #1 for 1601 | Dejust | | 25 Feb 2011 17:46 | 1 |
Please give a test № 1 for the task № 1601 |
| To admins | Hakobyan Tigran (RAU) | 1005. Stone Pile | 25 Feb 2011 14:00 | 2 |
To admins Hakobyan Tigran (RAU) 9 Feb 2011 01:26 Why this solution got AC ? For the first test it outputs 15, but correct answer is 3 !!!! #include <iostream> #include <complex> #include <algorithm> #include <cmath> #include <vector> #include <string> using namespace std; int main() { int n,i,total=0,counter; int l; vector <int> x; cin>>n; for(i=0; i<n; i++) { cin>>l; x.push_back(l); } for(i=0; i<n; i++) { total+=x[i]; } counter=total/2; for(i=0; i<n; i++) { if(x[i]<=counter) { counter-=x[i]; } } cout<<2*counter+total%2; return 0; } |
| Test №4: Output limit exceeded | Vitaliy_Yurenya | 1313. Some Words about Sport | 24 Feb 2011 21:32 | 2 |
I have tested my program on many tests, and I don't see any mistakes in my algorithm. What does mean "Output limit exceeded"? Please help. Thanks. Hi. I got WA at test #4 unless I declared variables as Integer instead of 1..100. Maybe it'll help you, if you still have that error Edited by author 25.02.2011 00:00 |
| So easy ! In this website, there are many problems similar to this problem. So, it costs me no efforts to solve it ! | Phan Hoài Nam (Harvey Nash) | 1282. Game Tree | 24 Feb 2011 15:14 | 1 |
Hint for you : int travel(int player,int node) { int value; if(isLeaf(node)) return getValue(node); // If the first player is at this node, he prefer getting the maximal value among -1, 0 and +1. if(player == 0) { value = MinValue(); for(int a=0;a<numberOfChild(node);a++) { int v = travel((player+1)%2,getChild(node,a)); if(value < v) value = v; } } // Get the minimal value. else { value = MaxValue(); for(int a=0;a<numberOfChild(node);a++) { int v = travel((player+1)%2,getChild(node,a)); if(value > v) value = v; } } return value; } Edited by author 24.02.2011 15:14 |
| TLE 11 HELP PLZ !!!!!! | Nikitoz68 | 1024. Permutations | 24 Feb 2011 03:50 | 1 |
#include <cstdio> using namespace std; int main() { int const Q=1001; long long unsigned k = 0,i,n,a=0; scanf("%llu",&n); long long unsigned mas1[Q]; long long unsigned mas2[Q]; for(i = 1;i<=n;i++) { scanf("%llu",&mas1[i]); mas2[i] = mas1[i]; } for(;;) { for(i = 1;i<=n;i++) { if (i == mas2[i]){ k++;} mas2[i] = mas1[mas2[i]]; } a++; if ( k == n) { break;} else {k = 0;} } printf("%llu\n",a); return 0; } |
| WA №9 What's wrong? who can tell me plz? | Nikitoz68 | 1024. Permutations | 24 Feb 2011 02:56 | 1 |
#include <cstdio> using namespace std; /* * */ int main() { long long k = 0; long long i; long long unsigned n; scanf("%llu",&n); long long unsigned mas1[1000]; long long unsigned mas2[1000]; for(i = 1;i<=n;i+=1) { scanf("%llu",&mas1[i]); mas2[i] = mas1[i]; } long long unsigned a = 0; long long s = 0; long long m = 0; do { for(long long j = 1;j<=n;j+=1) { if (j == mas2[j]){ k+=1;} } for(i = 1;i<=n;i+=1) { s = mas2[i]; mas2[i] = mas1[mas2[i]]; } if ( k == n) { m=1;} else {k = 0;} a+=1; } while (m!=1); printf("%llu\n",a); return 0; } |
| Warning: newline is required | Evgeniy++ | 1079. Maximum | 24 Feb 2011 00:54 | 2 |
Hello everyone! My program was accepted only with 'newline' output for each test case. Before that I`ve got I/A. You have been warned :) See you! |
| Wrong Answer. What's wrong in my program? I'm sure that i'm right! №1024 | Nikitoz68 | | 24 Feb 2011 00:51 | 1 |
#include <cstdio> using namespace std; /* * */ int main() {
unsigned int k = 0; unsigned int i; unsigned int n; scanf("%u",&n); unsigned int mas1[1000],mas2[1000]; for(i = 1;i<=n;i+=1) { scanf("%u",&mas1[i]); mas2[i] = mas1[i]; } unsigned int a = 0; unsigned int s = 0; unsigned int m = 0; do { for(int j = 1;j<=n;j+=1) { if (j == mas2[j]){ k+=1;} } for(i = 1;i<=n;i+=1) { s = mas2[i]; mas2[i] = mas1[s]; } if ( k == n) { m=1;} else {k = 0;} a+=1; } while (m!=1); printf("%u\n",a); return 0; } |
| WA 27 | Adrian Zaharia | 1238. Folding | 23 Feb 2011 23:36 | 1 |
WA 27 Adrian Zaharia 23 Feb 2011 23:36 Can I have a test for WA 27 please? |
| Getting Access Violation on Test #1 (Problem 1471) | Kinan Sarmini | | 23 Feb 2011 23:10 | 1 |
It's working now, had a simple bug. Edited by author 23.02.2011 23:34 |
| WA10 | Серовиков Андрей | 1564. Counting Ones | 23 Feb 2011 21:32 | 8 |
WA10 Серовиков Андрей 13 Oct 2007 14:53 What's wrong, if the second test is 10^18? the ones of 1 to 10^18 have over the range of int64 Re: WA10 Piratek-(akaDK) 16 Mar 2008 18:14 The number of ones is less than number of floor. For me tha answer must be in Int64 Re: WA10 Vedernikoff Sergey 17 Mar 2008 22:03 The answer is within Int64. So, try to find bug in your code or algorithm... Re: WA10 Chmel_Tolstiy 18 Mar 2008 19:44 if you use line like this at TIMUS will a bug ... long long INF = 1e18; you should use long long INF = 1e9; INF *= INF; Use unsigned __int64, might help. Also, if you use binary search, make sure that left+right does not overflow prior to /2 or >>1. if you use line like this at TIMUS will a bug ... long long INF = 1e18; you should use long long INF = 1e9; INF *= INF; Thank you! Try this test 12 Answer 19 (not 20) |
| Is the test case correct??? | 72VanVector[SevNTU] | 1817. Merry-go-round | 22 Feb 2011 05:58 | 15 |
consider the test case in problem statement. Will the kid really wait for 0.6875 sec, when 2 kids are riding merry-go round?? Mb this value should be 0.625 = 5/8??? Edited by author 30.01.2011 13:22 The test case is correct. it seems to be wrong at all there are 6 posibilities in this hypothesis (there are 2 childrens) they are: 1100 - 2 1010 - 1 1001 - 1 0110 - 0 0101 - 0 0011 - 0 so, the posibility must be 2*1/6 + 1*1/6 + 1*1/6 = 0.66666667 isn't it right?? Edited by author 30.01.2011 14:15 _________________________________________ test case is right. there are sub-hypothesis with different posibilities Edited by author 30.01.2011 14:54 Seems like the possibility of each case isn't equal to 1/6, some of the cases have more then 1/6, others - less. How did you do that?? Edited by author 30.01.2011 16:45 Yes, test case is correct. Look: 1010 you can get from 1000 and 0010, p = 2/16 0101 you can get from 0100 and 0001, p = 2/16 But: 1100 you can get from 1000 (2 times!) and 0100, p = 3/16 0110 you can get from 0100 (2 times!) and 0010, p = 3/16 0011 you can get from 0010 (2 times!) and 0001, p = 3/16 1001 you can get from 0001 (2 times!) and 1000, p = 3/16 Thus, we get: p(1100) = 3/16, p(1001) = 3/16, p(1010) = 2/16 And the answer is: (3/16)*2 + (3/16)*1 + (2/16)*1 = 11/16 = 0.6875 Nice problem! Look: 1010 you can get from 1000 and 0010, p = 2/16 0101 you can get from 0100 and 0001, p = 2/16 But: 1100 you can get from 1000 (2 times!) and 0100, p = 3/16 0110 you can get from 0100 (2 times!) and 0010, p = 3/16 0011 you can get from 0010 (2 times!) and 0001, p = 3/16 1001 you can get from 0001 (2 times!) and 1000, p = 3/16 Can you please explain why for 1010 -> p = 2/16 but 1100 -> p = 3/16 How does 1000 come 2 times in this case ? 1000 -> 1010 if start position = 3 0010 -> 1010 if start position = 1 (2 times) 1000 -> 1100 if start position = 1 1000 -> 1100 if start position = 2 0100 -> 1100 if start position = 1 (3 times) "And the answer is: ... + (3/16)*1 + = 11/16 = 0.6875" Could you explain why (3/16)*1 but not (3/16)*2, though max waiting time is 2 (1001 - if we stand at place 1)?? Mask Time 0011 0 0101 0 0110 0 1001 1 1010 1 1100 2 Sorry, but why 11/16? Why not 3/16 + 3/16 + 3/16 + 3/16 + 2/16 + 2/16 = 16/16 I understand that 4/16 == 0.250000 ====== 1000 1/16 0100 1/16 0010 1/16 0001 1/16 24/16 == 1.500000 ===== 1110 (3+2+1=6)/16 1101 (3+2+1=6)/16 1011 (3+2+1=6)/16 0111 (3+2+1=6)/16 But why 11/16? Just some basic knowledge from probability theory... 3/16 + 3/16 + 3/16 + 3/16 + 2/16 + 2/16 = 16/16 It's a normalization requirement (p1 + p2 + ... + pn = 1). And mean MX = p1*x1 + p2*x2 + ... + pn*xn, where pi - probabilities, xi - values. So we have (3/16)*2 + (3/16)*1 + (2/16)*1 + (3/16)*0 + (3/16)*0 + (2/16)*0 = 11/16. In Buffon problem there are 3 different solution and all of them are right. Answer depend on exact understanding all conditions of random experiment. I think that this problem also safer from too brief explanation. i've used this explanation of test: let it be some kind of class: 1100 0110 0011 1001 - first class, maked by all rotations of first one, and it's representative would be a smallest, so: [1100] : {1100 0110 0011 1001} [1010] : {1010 0101 1010 0101} - second class, we have repeatings here, but it must be always n rotations so, we could get [1100] from: 1000 - waiting 1 sec, 0001 - not waiting 0100 - not waiting all of them is class [1000] which comes from [0000] with 100% posibility so posibilities of [1000] would be: 1000 - 100% * 1 / 4 0001 - 100% * 1 / 4 0100 - 100% * 1 / 4 so posibility of getting in class [1100] is 3/4 [1010] we could get from: 0010 which posibility is 100% * 1 / 4 so our classes have such posibilities: [1100] - 3 / 4 [1010] - 1 / 4 [1100]: mask sec posibility 1100 2 1/4*3/4 0110 0 1/4*3/4 0011 0 1/4*3/4 1001 1 1/4*3/4 [1010]: mask sec posibility 1010 1 1/4*1/4 0101 0 1/4*1/4 1010 1 1/4*1/4 - it repeats, but it is another rotation, 3rd 0101 0 1/4*1/4 - 4th so, our result would be: MX = 2 * 3/16 + 1 * 3/16 + 1 * 1/16 + 1 * 1/16 = 11/16 = 0.6875 like in our test case i've used DP for this problem, just filling array of posibilities in recursive with saving way, rotating my current mask, and looking from where i could go here |
| ...delete... | The Godfather | | 21 Feb 2011 23:46 | 1 |
...delete... Edited by author 21.02.2011 23:47 |
| beware! problem statement is absolutely correct now | muhammad | 1334. Checkers | 21 Feb 2011 11:31 | 2 |
may b something was wrong previously. now it is correct. can't fall over boundary. must jump to empty cell. and only black cells. however, u must check - new checker may attack or be attacked :P Yes, it is somehow strange but if one of players put checker and this checker can attack the checker of another colour, so the game is stopped with the fool (!) of this player. Naturally, if this put checker could be attacked the end is the same. |