|
|
Общий форум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). //============================================================================ // 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. 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. 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:46I solved this problem by probabilistic approach and brute-force. No TLE, just stupid WA :) Hahaha. It's guro method! need help me please.... Edited by author 01.05.2009 17:09 Edited by author 01.05.2009 17:09 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? 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 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. I solve this task with DP, but wa#12... Please give me some useful tests. Thanks. to Admins!!! 2 2 1 1 result empty line or zero? 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; Please give me (show me) test#12. Thanks Edited by author 04.07.2009 01:20 Just use The Wave algorithm.. 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)))) ce ai? nu merge submit`u? Strange... Solving this problem I thought that rows are numbered from bottom to top. Edited by author 18.02.2010 20:17 Why I got MLE#3? I'm using 1 int[M][3] matrix to store the edges, 3 short[N+1] arrays for Union-find, and an additional short[N] to store the resulting spanning tree. Bug in qsort. Edited by author 18.02.2010 15:19 why it is wrong? "An arithmetic expression in D++ is always opened by "(", is closed by ")" and may contain any of the following symbols: "=+-*/0123456789)("" arithmetic expression is opened by '(',may contain '*'and closed by ')'.so "(*)" can seen as a right arithmetic expression. anyone can answer me?? my AC'ed solution says that (*) is NOT a legal expression. Either the test set does not have such things, or judges do not consider (*) to be an arithmetic expr An arithmetic expression can't start with a pair of symbols "(*" In my opinion, (*) is valid COMMENTARY - it's opened by (* and closed by *) ; I think we need to add "and these two pairs of symbols should not intersect" to this phrase in statement - " A comment is always opened by a pair of symbols "(*" and is closed by a pair of symbols "*)" , otherwise (*) is YES for sure. Edited by author 16.02.2010 13:52 In my opinion, (*) is valid COMMENTARY - it's opened by (* and closed by *) ; I think we need to add "and these two pairs of symbols should not intersect" to this phrase in statement - " A comment is always opened by a pair of symbols "(*" and is closed by a pair of symbols "*)" , otherwise (*) is YES for sure. You is very crazy man :) I think, that you never write syntax analyzer for languages. You "additional condition" is obvious for all, that ever write syntax analyzers, but not for you. :) This problem is about syntax analyzer , NOT working with any string and substrings. Edited by author 16.02.2010 21:12Dear Team, It is really very good support by you. But please, look at the problem 1001-in java. There might be problem in compiler-there is no one who solved this question in java. I will include my answer too.: import java.util.Scanner; public class second{ public static void main(String[] args) { Scanner s = new Scanner(System.in); double[] arr2=new double[200000]; int i=0,k=0; do{ arr2[k]=s.nextDouble(); k++; } while(s.hasNext()); for(i=k;i>0;i--){ System.out.printf("%.4f\n",Math.sqrt(arr2[i-1])); } } } Are you kidding :) Many people solved this problem in Java. I am among them. Edited by author 16.02.2010 21:05 My solution use emulation with some heuristic conditions (for avoiding deadlock). Solution is o(n). Some test: 1 output 3 0 2 1 -------- 2 output 8 1 3 4 2 0 1 3 2 -------- 3 output 15 2 4 5 3 1 0 2 4 6 5 3 1 2 4 3 -------- 4 output 24 3 5 6 4 2 1 3 5 7 8 6 4 2 0 1 3 5 7 6 4 2 3 5 4 -------- 5 output 35 4 6 7 5 3 2 4 6 8 9 7 5 3 1 0 2 4 6 8 10 9 7 5 3 1 2 4 6 8 7 5 3 4 6 5 |
|
|