Общий форум| Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения | | C compiler does not follow C99 Standard | Tony Beta Lambda | 1010. Дискретная функция | 25 фев 2010 12:24 | 3 | C99 7.20.6.1: long long int llabs(long long int j); but when I submit my code with use of llabs, I got CE. fmax(double,double) also doesn't work well LLONG_MAX will get CE too. | | WA2,……help me | MeLodyloveyr | 1750. Пахом и овраг | 25 фев 2010 12:19 | 1 | I use shortest path to solve this problem... | | Why WA 8? | 李春骐 | 1016. Кубик на прогулке | 25 фев 2010 10:51 | 2 | I used SPFA, but failed in test 8. Who can help me? #include <stdio.h> #include <string.h> #define INF 0x3f3f3f3f int op[] = {0, 2, 1, 5, 6, 3, 4}; int r[7][7] = { {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 4, 5, 6, 3}, {0, 0, 0, 6, 3, 4, 5}, {0, 6, 4, 0, 1, 0, 2}, {0, 3, 5, 2, 0, 1, 0}, {0, 4, 6, 0, 2, 0, 1}, {0, 5, 3, 1, 0, 2, 0} }; struct State { int x, y, b, f; //表示坐标(x, y)和底面和前面上的标号 } beg, end, que[24*8*8*100]; bool inque[9][9][7][7]; int dist[9][9][7][7], a[7], path[24*8*8*2]; int ans = 1000000000, last; char s1[4], s2[4]; void eval(State &s, int x, int y, int b, int f) { s.x = x, s.y = y, s.b = b, s.f = f; } bool check(State &s) { if (s.x == 0 || s.x > 8 || s.y == 0 || s.y > 8) return 0; return 1; } void SPFA() { int closed = 0, open = 2; memset(dist, 0x3f, sizeof(dist)); eval(que[1], beg.x, beg.y, beg.b, beg.f); inque[beg.x][beg.y][beg.b][beg.f] = 1; dist[beg.x][beg.y][beg.b][beg.f] = 0; do { closed++; inque[que[closed].x][que[closed].y][que[closed].b][que[closed].f] = 0; if (que[closed].x == end.x && que[closed].y == end.y && dist[que[closed].x][que[closed].y][que[closed].b][que[closed].f] < ans) { ans = dist[que[closed].x][que[closed].y][que[closed].b][que[closed].f]; last = closed; } State newst; // forward eval(newst, que[closed].x, que[closed].y-1, que[closed].f, op[que[closed].b]); if (check(newst)) { if (dist[newst.x][newst.y][newst.b][newst.f] > dist[que[closed].x][que[closed].y][que[closed].b][que[closed].f] + a[newst.b]) { dist[newst.x][newst.y][newst.b][newst.f] = dist[que[closed].x][que[closed].y][que[closed].b][que[closed].f] + a[newst.b]; if (!inque[newst.x][newst.y][newst.b][newst.f]) { inque[newst.x][newst.y][newst.b][newst.f] = 1; que[open] = newst; path[open] = closed; open++; } } } // right eval(newst, que[closed].x+1, que[closed].y, r[que[closed].b][que[closed].f], que[closed].f); if (check(newst)) { if (dist[newst.x][newst.y][newst.b][newst.f] > dist[que[closed].x][que[closed].y][que[closed].b][que[closed].f] + a[newst.b]) { dist[newst.x][newst.y][newst.b][newst.f] = dist[que[closed].x][que[closed].y][que[closed].b][que[closed].f] + a[newst.b]; if (!inque[newst.x][newst.y][newst.b][newst.f]) { inque[newst.x][newst.y][newst.b][newst.f] = 1; que[open] = newst; path[open] = closed; open++; } } } // backward eval(newst, que[closed].x, que[closed].y+1, op[que[closed].f], que[closed].b); if (check(newst)) { if (dist[newst.x][newst.y][newst.b][newst.f] > dist[que[closed].x][que[closed].y][que[closed].b][que[closed].f] + a[newst.b]) { dist[newst.x][newst.y][newst.b][newst.f] = dist[que[closed].x][que[closed].y][que[closed].b][que[closed].f] + a[newst.b]; if (!inque[newst.x][newst.y][newst.b][newst.f]) { inque[newst.x][newst.y][newst.b][newst.f] = 1; que[open] = newst; path[open] = closed; open++; } } } // left eval(newst, que[closed].x-1, que[closed].y, op[r[que[closed].b][que[closed].f]], que[closed].f); if (check(newst)) { if (dist[newst.x][newst.y][newst.b][newst.f] > dist[que[closed].x][que[closed].y][que[closed].b][que[closed].f] + a[newst.b]) { dist[newst.x][newst.y][newst.b][newst.f] = dist[que[closed].x][que[closed].y][que[closed].b][que[closed].f] + a[newst.b]; if (!inque[newst.x][newst.y][newst.b][newst.f]) { inque[newst.x][newst.y][newst.b][newst.f] = 1; que[open] = newst; path[open] = closed; open++; } } } } while (closed < open); } void print(int i) { if (que[i].x == beg.x && que[i].y == beg.y) { printf("%d %c%d", ans+a[beg.b], beg.x+'a'-1, beg.y); return; } print(path[i]); printf(" %c%d", que[i].x+'a'-1, que[i].y); } int main() { scanf("%s%s%d%d%d%d%d%d", s1, s2, &a[1], &a[2], &a[3], &a[4], &a[5], &a[6]); beg.x = s1[0] - 'a' + 1; beg.y = s1[1] - '0'; beg.b = 5; beg.f = 1; end.x = s2[0] - 'a' + 1; end.y = s2[1] - '0'; SPFA(); print(last); printf("\n"); return 0; } | | Place more samples!!!(-) | Sergey Lazarev (MSU Tashkent) | 1524. Men in Black | 24 фев 2010 21:04 | 6 | Aga. Another more sophisticated sample would be very helpful! It seems that all tests including Test 4 are correct. But still WA4... What the f... I missed? To nikonoff. Sergey Lazarev (MSU Tashkent) 21 фев 2010 20:53 I suggest to exchange our tests and compare answers to find mistakes. Agreed Edited by author 24.02.2010 14:03 | | timus_support@acm.timus.ru does not work | Fyodor Menshikov | | 24 фев 2010 18:51 | 2 | I got the following answer when tried to send test to Timus team: ----- The following addresses had permanent fatal errors ----- judge_mailbox@busin.usu.ru (reason: 550 5.1.1 User unknown) (expanded from: <timus_support@acm.timus.ru>) ----- Transcript of session follows ----- 550 5.1.1 judge_mailbox@busin.usu.ru... User unknown I have received your message. But one of the other recipients had a problem with his mailbox. This mailbox is fixed now. | | WA 7 | Marginean Ciprian | 1587. Летающая свинья | 23 фев 2010 20:40 | 1 | WA 7 Marginean Ciprian 23 фев 2010 20:40 Maybe someone could give me some tests to find the bug in my program. I have tried the tests on this forum(and others) and it provides the correct answer(for those tests). L.E.: Never mind, I got accepted. Using an automated test generator, which I wrote, I found that my program failed to provide a correct answer on the following test: //Input 2 -1 -1 //Correct Output 1 //My Output -1 And obviously, it failed all tests of the type n -1 -1 ... -1 by providing the answer -1. Maybe this will help others of wasting a few days on the problem. Edited by author 23.02.2010 21:27 | | Why i got crash??? | Rudnev Vladimir | 1585. Пингвины | 23 фев 2010 00:32 | 4 | what's wrong??? var a:array[1..1000] of string;v,b,c,n,i:integer; begin b:=0;c:=0;v:=0; read(n); for i:=1 to n+1 do begin readln(a[i]); if a[i]='Emperor Penguin' then v:=v+1; if a[i]='Macaroni Penguin' then b:=b+1; if a[i]='Little Penguin' then c:=c+1; end; if (v>b)and(v>c)then writeln('Emperor Penguin'); if (b>v)and(b>c)then writeln('Macaroni Penguin'); if (c>b)and(c>v)then writeln('Little Penguin'); end. Why "for i:=1 to n+1 do"??? Must be "for i:=1 to n do"!!! if i do "for i:=1 to n do" then (не знаю как дальше поанглийски) Короче он вводит на 1 меньше Change "read(n)" to "readln(n)". | | What's wrong??? | Rudnev Vladimir | 1545. Иероглифы | 22 фев 2010 23:29 | 3 | Why I got crash on 10 test???? var a:array[1..100]of string; n,i:integer; c:string; begin read(n); for i:=1 to n+1 do readln(a[i]); readln(c); for i:=1 to n+1 do if pos(c,a[i])=1 then writeln(a[i]); end. Because 1<=N<=1000 (not 1<=N<=100). | | Why wa #3?? | efrenfuentes | 1001. Обратный корень | 22 фев 2010 23:11 | 2 | //============================================================================ // Name : 1001. Reverse root // Author : Efrén Fuentes // Version : 1.00 // Copyright : Efrén Fuentes. 2010 // Description : Imprimir las raices cuadradas en orden inverso //============================================================================ #include <stdlib.h> #include <iostream> #include <iomanip> #include <cmath> using namespace std; class Nodo { public: long double valor; Nodo *anterior; }; class Pila { public: Nodo *tope; Pila() { tope = NULL; } void Push(long double valor) { Nodo *nuevo = new Nodo(); nuevo->valor = valor; nuevo->anterior = tope; tope = nuevo; } void PushRaiz(long double valor) { Push(sqrt(valor)); } long double Tope() { Nodo *ultimo = tope; long double valor = tope->valor; tope = ultimo->anterior; return valor; } }; int main() { // declarar variables long double numero; Pila *pila = new Pila(); // leer valores while(!cin.eof()) { cin >> numero; pila->PushRaiz(numero); } // el ultimo numero ingresa dos veces en la pila // hay que eliminarlo pila->Tope(); // formatear la salida con 4 decimales cout << setiosflags(ios::fixed) << setprecision(4); // mostrar las raices while(pila->tope != NULL) { cout << pila->Tope() << endl; } return EXIT_SUCCESS; } Read FAQ: sizeof(long double) == sizeof(double) == 8 byte. You should use "long long" for such big numbers as 10^18. | | C Compiler not compatible with C99? | Tony Beta Lambda | 1020. Ниточка | 22 фев 2010 19:33 | 1 | C99 7.12.7.3 (page 228) specifies the hypot functions. But I suspect that there is something wrong with them here. When I call hypot() to calculate the distance I got WA. But if adding this fragment of code: double dist(double x, double y) { return sqrt(x * x + y * y); } and call dist() instead of hypot() I got AC. Seems the C Compiler is not compatible with C99. I hope the administrators can update their C compiler. | | Weak time limit | Fyodor Menshikov | 1375. Нонконформизм | 22 фев 2010 13:38 | 2 | Upgrade of Timus test server happened on autumn 2008. I became several times faster, but very few time limits were changed. This problem is one that needs time limit to be lowered. Because with 1s TL and new servers some brute force solutions get AC - solutions that would never get AC on old testing server. I suggest TL=0.2s considering that some languages (Java and C#) need about 0.1s to start program. I became several times faster,... OMG :) I think, that good brute-force solution on С++ avoid TLE and after lowering TL (some authors write about it at forum ). So i think, that your suggest will be rejected. Edited by author 22.02.2010 13:46 | | Probabilistic approach | unlucky [Vologda SPU] | 1095. Никифор 3 | 22 фев 2010 01:25 | 3 | I solved this problem by probabilistic approach and brute-force. No TLE, just stupid WA :) Hahaha. It's guro method! | | WA #2 | Sourse | 1587. Летающая свинья | 21 фев 2010 23:27 | 2 | WA #2 Sourse 1 май 2009 17:08 need help me please.... Edited by author 01.05.2009 17:09 Edited by author 01.05.2009 17:09 | | why is that? anyone please help | null | 1712. Шифровальная решётка | 21 фев 2010 16:11 | 1 | ofcourse i've tried it on my computer it runs that program just fine i've tried submitting my solution 3 times. why is it giving me CE and WA can anyone explain it? | | WA#6 | jagatsastry | 1084. Пусти козла в огород | 20 фев 2010 23:25 | 3 | WA#6 jagatsastry 28 ноя 2007 21:38 Is there anyone who's got AC after getting WA#6 and then rectifying his code. Any tricky test case. Edited by author 28.11.2007 21:39 the test where all square is available... for example 9 8 correct is 81 but my answer was 70.93292183 Re: WA#6 Vovan [SL-StekoL] 20 фев 2010 23:25 | | What's wrong here? | Xysia | 1502. Точки домино | 20 фев 2010 20:12 | 2 | All codes listed below works good on my computer (and they give correct answers), but when submitting I get: Code #1: --------------------------------------------------------- #include<stdio.h> #include<iostream.h> int main() { long long n; cin>>n; long long wynik; wynik=(n*(n+1)*(n+2))/2; cout<<wynik<<endl; return 0; } ---------------------------------------------------------- Compilation error Code #2: removed iostream.h and replaced cin and cout with scanf("%lld",%n); and printf("%lld\n",wynik); WA on test 5 Code #3: same as #2, but with printf("%0.lf\n, (double)wynik); instead WA on test 1 ----------------------------------------------------------- All those programs work and give correct results on my computer. What's wrong here? Please help. For The First Code : Add using namespace std; for using cin & cout. | | Wonder what's the solutions which runs in 0.1 second? | Gandalf | 1669. Универсальное слово | 20 фев 2010 18:29 | 1 | | | wa#12 | Crash_access_violation | 1244. Джентльмены | 20 фев 2010 16:57 | 7 | wa#12 Crash_access_violation 15 мар 2009 14:09 I solve this task with DP, but wa#12... Please give me some useful tests. Thanks. wa#12 Crash_access_violation 15 мар 2009 14:12 to Admins!!! 2 2 1 1 result empty line or zero? Re: wa#12 [LG]_#\#@P$T[101]R 30 апр 2009 14:46 Also have WA #12 (now). The test above is incorrect (weight of not full set is strongly less than weight of full set of cards by condition) I lost this fragment: if(f[i][1-page]==-1) f[i][page]=-1; or if(f[i][j-1]==-1) f[i][j]=-1; Re: wa#12 [LG]_#\#@P$T[101]R 4 июл 2009 01:06 Please give me (show me) test#12. Thanks Edited by author 04.07.2009 01:20 | | Got AC | zam_sabina | 1319. Отель | 19 фев 2010 23:41 | 1 | Got AC zam_sabina 19 фев 2010 23:41 Just use The Wave algorithm.. | | Solution for (0<A+B<10^2^64-1) | VladimirZagorodskih | 1000. A+B Problem | 19 фев 2010 20:04 | 4 | program Project1; {$APPTYPE CONSOLE} var sym : char; a, b : AnsiString; la, lb, i : qword; l, m, n : byte; c : array of byte; begin read(sym); repeat a:=a+sym; read(sym); until (sym=' '); readln(b); la:=length(a); lb:=length(b); if la>lb then setlength(c, la) else setlength(c, lb); i:=0; n:=0; repeat i:=i+1; if la>0 then l:=ord(a[la])-48 else l:=0; if lb>0 then m:=ord(b[lb])-48 else m:=0; c[i]:=l+m+n; n:=c[i] div 10; c[i]:=c[i] mod 10; if la>0 then la:=la-1; if lb>0 then lb:=lb-1; until (la<=0) and (lb<=0) and (n=0); while (i>0) do begin write(c[i]); i:=i-1; end; end. =) (= just high precision, but a bit slow Or just use unsigned long long in C... I know that this problem can be solved by this: program Project1; {$APPTYPE CONSOLE} uses SysUtils; var a, b : longint; begin read(a,b); write(a+b); end. I did it just for fun)))) |
|
|