Common BoardC99 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 Please tell me. Thanks. "If there are many solutions, you may output any of them." #include <iostream> using namespace std; #include <math.h> struct Point { long double x; long double y; }; struct Point2 { int number; long double angle; }; void insertSort(Point2 ** a, long size) { Point2 * x; long i, j; for ( i=0; i < size; i++) { // цикл проходов, i - номер прохода x = a[i];
// поиск места элемента в готовой последовательности for ( j=i-1; j>=0 && (a[j]->angle < x->angle); j--) a[j+1] = a[j]; // сдвигаем элемент направо, пока не дошли // место найдено, вставить элемент a[j+1] = x; } } /* int compare( const void *arg1, const void *arg2 ) { if(((Point2*)arg1)->angle>((Point2*)arg2)->angle) return -1; else return 1;
}*/ int main() {
int n; cin>>n; Point * arr = new Point[n]; long double min_a=0; int min_ai; for(int i = 0;i<n;++i) { cin>>arr[i].x; cin>>arr[i].y; if((!i)||arr[i].y<min_a) { min_a = arr[i].y; min_ai = i; } } cout<<min_ai+1<<" "; Point2 ** arr2 = new Point2*[n-1]; int j = 0; long double xx = arr[min_ai].x; long double yy = arr[min_ai].y; for(int i = 0;i<n;++i) { if(i!=min_ai) { arr2[j] = new Point2; arr2[j]->number = i; arr2[j]->angle = (arr[i].x - xx)/sqrt(pow(arr[i].x-xx,2)+pow(arr[i].y-yy,2)); ++j; } } //qsort(arr2,n-1,4,compare); insertSort(arr2,n-1); cout<<arr2[(n-1)/2]->number+1<<endl; return 0; } I don't know why, but qsort sorts them wrongly (I commented part that is qsort and changed it with simple O(n^2) sorting and got AC... But could tell me, what's so wrong with this qsort? I think I could get a better time with it. In this task qSort works very quick :) But you time is not very bad ;) If you will use sort from <algortihm>, you will get AC. http://www.cplusplus.com/reference/clibrary/cstdlib/qsort/I changed int compare( const void *arg1, const void *arg2 ) { if(((Point2*)arg1)->angle>((Point2*)arg2)->angle) return -1; else return 1; to int compare( const void *arg1, const void *arg2 ) { if(((Point2*)arg1)->angle>((Point2*)arg2)->angle) return 1; else return -1; according to conditions presented in the href above. On my computer I get answer "1 4" on first test, but on server in gets WA #1. /* qsort example */ #include <stdio.h> #include <stdlib.h> int values[] = { 40, 10, 100, 90, 20, 25 }; int compare (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } int main () { int n; qsort (values, 6, sizeof(int), compare); for (n=0; n<6; n++) printf ("%d ",values[n]); return 0; } It is very very strange. QSort does not work here. Use Merge or Heap sort. |
|