Common Board| Show all threads Hide all threads Show all messages Hide all messages | | How I avoid ML | sos1g3 [TSOGU] | 1102. Strange Dialog | 8 Mar 2013 01:14 | 2 | I use bit operations for this problem =) and simple DP =) It has AC with ~4Mb memory and ~0.7 sec time... I got AC using 2 arrays of size 10^7 without bit compression. Strange... | | wa on test #15 | cpcs | 1432. Twofold Luck | 7 Mar 2013 10:31 | 1 | Could anyone give me some test cases? Thanks. Edited by author 07.03.2013 11:16 Edited by author 07.03.2013 11:16 Edited by author 07.03.2013 11:17 Edited by author 07.03.2013 11:17 | | Haskell need help, please | Konstantin | 1000. A+B Problem | 7 Mar 2013 09:24 | 3 | I'm only start to learn Haskell. I'm confused with std function and IO. My solution (does not work): main = do a <- getLine let b = sum map read words a // <- I try to use this functions putStrLn (show b) let b = words a // work, but let b = sum map (read::Int) words a //does not work Where I wrong? | | WA#17 | RocBoy-D | 1777. Anindilyakwa | 6 Mar 2013 23:21 | 11 | WA#17 RocBoy-D 7 Aug 2012 19:15 #include <stdio.h> #include <stdlib.h> int cmp(const void *a, const void *b) { unsigned long long *pa = (unsigned long long *)a, *pb = (unsigned long long *)b; return *(unsigned long long *)pa - *(unsigned long long *)pb; } int main() { unsigned long long arr[15000], min=1000000000000000000; int N=3, count=0, i; for(i = 0; i<N; i++) scanf("%llu", &arr[i]); while(min) { qsort (arr, N, sizeof(unsigned long long), cmp); for (i = 0; i<N-1; i++) if(arr[i+1] - arr[i]<min) min=arr[i+1] - arr[i]; arr[N++] = min; count++; } printf("%d", count); return 0; } Can anybody help me? Re: WA#17 Andrew Sboev [USU] 7 Aug 2012 21:07 Use __int64 instead of unsigned long long I changed. But I stil have WA#17 and time limit exceed. #include <stdio.h> #include <stdlib.h> int cmp(const void *a, const void *b) { __int64 *pa = (__int64 *)a, *pb = (__int64 *)b; return *(__int64 *)pa - *(__int64 *)pb; } int main() { __int64 arr[100], min=1000000000000000000; int N=3, count=0, i; for(i = 0; i<N; i++) scanf("%I64d", &arr[i]); while(min) { qsort (arr, N, sizeof(__int64), cmp); for (i = 0; i<N-1; i++) if(arr[i+1] - arr[i]<min) min=arr[i+1] - arr[i]; arr[N++] = min; count++; } printf("%d", count); return 0; } Now I have WA#17 and crash(acces violation). Re: WA#17 Andrew Sboev [USU] 7 Aug 2012 22:29 Of course, you have crash :D Replace all number types to __int64, uncluding int. I changed: #include <stdio.h> #include <stdlib.h> int cmp(const void *a, const void *b) { __int64 *pa = (__int64 *)a, *pb = (__int64 *)b; return *(__int64 *)pa - *(__int64 *)pb; } int main() { __int64 arr[100], min=1000000000000000000, N=3, count=0, i; for(i = 0; i<N; i++) scanf("%I64d", &arr[i]); while(min) { qsort (arr, N, sizeof(__int64), cmp); for (i = 0; i<N-1; i++) if(arr[i+1] - arr[i]<min) min=arr[i+1] - arr[i]; arr[N++] = min; count++; } printf("%I64d", count); return 0; } But the same problem remain: WA#17 crasn(access violation) Re: WA#17 Andrew Sboev [USU] 8 Aug 2012 11:02 You didn't changed int cmp(const void *a, const void *b) { __int64 *pa = (__int64 *)a, *pb = (__int64 *)b; return *(__int64 *)pa - *(__int64 *)pb; } change to __int64 cmp(const void *a, const void *b) { __int64 *pa = (__int64 *)a, *pb = (__int64 *)b; return *(__int64 *)pa - *(__int64 *)pb; } #include <stdio.h> #include <stdlib.h> __int64 cmp(const void *a, const void *b) { __int64 *pa = (__int64 *)a, *pb = (__int64 *)b; return *(__int64 *)pa - *(__int64 *)pb; } int main() { __int64 arr[100], min=1000000000000000000, N=3, count=0, i; for(i = 0; i<N; i++) scanf("%I64d", &arr[i]); while(min) { qsort (arr, N, sizeof(__int64), cmp); for (i = 0; i<N-1; i++) if(arr[i+1] - arr[i]<min) min=arr[i+1] - arr[i]; arr[N++] = min; count++; } printf("%I64d", count); return 0; } No, it doesn't help. Re: WA#17 Andrew Sboev [USU] 8 Aug 2012 17:27 Oh,you have too small array size. Use STL vector do it greater. I don't know C++. I tried to change size of array, but I have time limit exceed. Edited by author 08.08.2012 18:32 # include <iostream> # include <vector> # include <algorithm> using namespace std; long long q; int main() { vector <long long> v(3),v1;
for(int i=0; i<3; i++) cin>>v[i];
while(1) { v1.clear();
q++;
for(int i=0; i<(int)v.size(); i++) { for(int h=0; h<(int)v.size(); h++) { if(i!=h) { int a=v[i]-v[h];
if(a>=0) v1.push_back(a); } } }
sort(v1.begin(),v1.end());
if(v1[0]==0) {break;}
v.push_back(v1[0]); } cout<<q; } | | Be aware of TEST 3 in JAVA | Hikmat Ahmedov | 1711. Code Names | 6 Mar 2013 11:06 | 1 | In JAVA version of the tests, in test 3, N<3, be careful when declaring array sizes. In C# version of the tests there is no such test. | | Runtime Error on #26 - Python 2.7 | skullgoblet1089 | 1785. Lost in Localization | 6 Mar 2013 05:14 | 1 | This code results in a runtime error at test #26: from sys import stdout d = int(float(raw_input().strip())) n = [1,5,10,20,50,100,250,500,1000,2000] l = ['few','few','several','pack','lots','horde','throng','swarm','zounds','legion','legion'] a = min(map(lambda x: x+d,filter(lambda x: x > 0, map(lambda x:x - d,n)))) stdout.write(l[n.index(a)]) This code was accepted without error: from sys import stdout d = int(raw_input()) if d > 0 and d < 5: stdout.write('few') elif d < 10: stdout.write('several') elif d < 20: stdout.write('pack') elif d < 50: stdout.write('lots') elif d < 100: stdout.write('horde') elif d < 250: stdout.write('throng') elif d < 500: stdout.write('swarm') elif d < 1000: stdout.write('zounds') else: stdout.write('legion') Can anyone explain why the first code fails but the second doesn't? | | A way to solve this problem in java | 2rf | 1269. Obscene Words Filter | 6 Mar 2013 01:10 | 1 | Initially, in one trie node i stored: Node child, sibling, sufLink; byte parSymb; short lEnd; This is 4 * 3 + 1 + 2 = 15 bytes per node, ML 28. Then I used static array of nodes(maximum number of nodes is 99991), memory consumption per node is the same(instead of Node reference we store int), ML 28. At the end, I stored child, sibling, sufLink and parSymb(we need 17 bits for each memory pointer and 8 bits for parent symbol, 17 * 3 + 8 = 59 bits in total) in one long, and lEnd in short, only 10 bytes per node, and got AC! | | what's wrong with my code c???????????????????????? | Abhijit Das | 1068. Sum | 5 Mar 2013 23:44 | 1 | #include<stdio.h> int main() { long long i,n; while(scanf("%lld",&n)==1) { long long s=0; if(n==1) printf("%lld",n); if(n>1&&n<=10000) { for(i=1;i<=n;i++) { s=s+i; } } if(n<1&&n>=-10000) { for(i=1;i>=n;i--) { s=s+i; } } printf("%lld\n",s); } return 0; } | | Help me pls.WA #2 | Accepted | 1090. In the Army Now | 5 Mar 2013 19:02 | 1 | Help me!!!I got WA#2 Please give me some tests... I use merge sort. | | To admins | artyomushko | 1290. Sabotage | 5 Mar 2013 18:28 | 4 | Здравствуйте, прошу прощения за русский язык (проблемы с английским)... Число 1 не строго больше одного, а значит, ошибка в условии задачи, т.к. при Вашем условии при вводе 4 1 6 на принтер выведется 2 2 1 1 и вывод программы будет 2... Исправьте, пожалуйста, условие для того чтобы не возникали недоразумения. СПАСИБО! "Функция организует следующую процедуру: на принтер выводит количество чисел в массиве, далее количество чисел, строго больших одного, ..." Именно это я и имел в виду! "далее количество чисел, строго больших одного..." А у в примере единица также учитывается... Первое число - количество ВСЕХ чисел в массиве! | | Test 1 help please. | freelife | 1209. 1, 10, 100, 1000... | 5 Mar 2013 01:54 | 2 | Hi! Please help russian shoolboy Where the error is? I realized that '1'-s are in the field of the sequence. 1 2 4 7 11 16 int main() { long a,j,i,n; cin>>n; for(int x=0; x<n; x++) { cin>>a; i=1; j=1; while (a>i) { i=i+j; j++; } if (a==i) cout<<1; else cout<<0; } return 0; } while (a>i) { i=i+j; j++; } | | Re: To Admins! | kami_botanik | | 4 Mar 2013 22:59 | 2 | Sorry, I have it, I just forgive write it at the sample for you. Program code has generate 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 isn't right? Xax! Sorry again. I have Acc, I just was to add "space" between numbers :) | | To Admins! | kami_botanik | 1313. Some Words about Sport | 4 Mar 2013 22:50 | 3 | Hi! Sorry, how i can have WA 1# if my program generate 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 at first test? Re: To Admins! Vedernikoff 'Goryinyich' Sergey (HSE: АОП) 4 Mar 2013 22:46 Do you have 16 in the end of the list? Look at the sample output - it is there Sorry, I have it, I just forgive write it at the sample for you. Program code has generate 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 isn't right? | | Very intersting | Aguero | 1201. Which Day Is It? | 4 Mar 2013 21:23 | 4 | If I get WA#10 then I'm not right, but all tests in the forum I solved correcyly! It is so strnage! If you have some idea about this, may you write me? thank's a lot fuck! my box is barcelonaaaa@yandex.ru I have the same situation with my program as Aguero. paul.martynov@gmail.com | | Finally Accept!!! | Accepted | 1069. Prufer Code | 4 Mar 2013 20:12 | 1 | I've written the program for many times,but when I submited it,I always see "MLE" or "Wrong Answer",I've submitted it for more than 10 times!!! Finally Accepted!!! | | Help me pls.WA #2 | Accepted | 1069. Prufer Code | 4 Mar 2013 11:05 | 1 | OK I've found that my heap is error,and I got MLE then. Edited by author 04.03.2013 19:32 Edited by author 04.03.2013 19:32 | | Need some tests! Help please! | NewGeneration | 1256. Cemetery Guard | 4 Mar 2013 04:15 | 1 | Can you help me? Tried different tests and answers are right, but here...every time I read the same: "Wrong answer". | | test 2 error | fryette | 1601. AntiCAPS | 4 Mar 2013 03:52 | 1 | what in test 2? Edited by author 04.03.2013 20:20 Edited by author 04.03.2013 20:20 | | TLE 54, what is wrong with Java? | Hikmat Ahmedov | 1593. Square Country. Version 2 | 3 Mar 2013 16:50 | 1 | I followed the algorithm of luckysundog which is posted in this forum and solved it C# and C++. The same code in C# and C++ gives AC, but in Java it gives Time Limit Exceeded in test 45. I improved the code to run faster but now it gives TLE 54. I tested the code against worst case of 1000000000000037, which is a prime number. And execution time for this test was 138 milliseconds which is obviously less than 1000 (1 second). For prime 10000000000000061, it takes 185 milliseconds. Does anybody know what test 54 is? Did anybody solve this problem in Java? Can you please send me the solution to hazorman@gmail.com Thanks, | | Please Help! Program is right! But I don't know what's a problem? | kami_botanik | 1313. Some Words about Sport | 3 Mar 2013 05:32 | 1 | I know you must'll say that this is like a "Axe slyle" But i sit on this task aproximately 7 hours! And I have already sick of it, but i owed to finish it! However Programm is working! I tested it and it's all right! PLEASE HEEEELP me! I have WA# 2. (((
using System; namespace ConsoleApplication1 { class Program14 { static void Main() { int p = 0; int u = 0; int q = 0; int k = 0; int i = 0; int j = 0; int n = int.Parse(Console.ReadLine()); string[] str; int[,] x = new int[n,n]; for (i = 0; i < n; i++) { str = Console.ReadLine().Split(' '); for (p = 0; p < n; p++) x[i, p] = int.Parse(str[p]); }
int[] y = new int[x.Length]; for (i = 1; i >= 0; i--) { k++; y[k] = x[i, k - 1];
for (j = 2; j >= 0; j--) { q++; if (q == 4) break; y[q + 2] = x[j, q - 1];
for (int o = 3; o >= 0; o--) { u++; if (u >= 5) break; y[u+5] = x[o, u - 1]; } }
} for (i = 3; i >= 2; i--) { y[k + 11] = x[i, k]; k++; } for (i = 3; i >= 1; i--) { q++; y[q+5] = x[i, q-4]; } y[0] = x[0, 0]; y[15] = x[3, 3]; foreach (int s in y) Console.Write("{0} ", s); Console.ReadLine();
} } }
Please prompt, Where is the problem! And sorry for my also "Dehqon style" english. |
|
|