Common Board| Show all threads Hide all threads Show all messages Hide all messages | | I THINK THE EXAMPLE IS WRONG !!! plz take a look | Manastireanu | 1062. Triathlon | 24 Nov 2007 18:00 | 3 | I think the correct output for the example should be: YES YES YES NO NO NO NO //not YES NO YES if I am wrong plz tell me why this is the way i thought of solving the problem STEP 1: --sort the contestants in descending order: after v | after W | after u 10 2 6 | 1 8 7 | 5 6 7 10 7 3 | 10 7 3 | 3 2 7 10 4 2 | 5 6 7 | 3 5 7 8 4 6 | 3 5 7 | 1 8 7 6 2 6 | 8 4 6 | 10 2 6 5 6 7 | 10 4 2 | 6 2 6 3 2 7 | 10 2 6 | 8 4 6 3 5 7 | 3 2 7 | 10 7 3 1 8 7 | 6 2 6 | 10 4 2 STEP 2: --only the first of each sort might be winners => after v | after w | after u 10 2 6 | 1 8 7 | 5 6 7 10 7 3 | | 3 2 7 10 4 2 | | 3 5 7 | | 1 8 7 STEP 3: --I sort the three columns after the other 2 speeds column 1 --after w and than u --after u and than w column 2 ... STEP 4: -- the first of every sort is surely a winner in conclusion i sort the competitors after: vwu vuw wvu wuv uvw uwv and the first of every sort is a winner hope you cold understand me :) PS: -if you have a nother idea post it plz -if the example is ok than plz tell me why Edited by author 20.02.2005 18:51 STEP 2 is wrong. Try this: 4 100 100 1 100 1 100 1 100 100 50 50 50 The answer should be: YES YES YES YES!!! A my idea. We should find answer for the first contestant. a[i] b[i] c[i] - is the speeds. x y z - the lengths. Write inequation describing that first contestant will win over i-th: (1/a[1] - 1/a[i])x + (1/b[1] - 1/b[i])y + (1/c[1] - 1/c[i])z < 0 Then, we should answer: are exist such x, y and z, that satisfy this inequations for each i > 1? Edited by author 30.03.2005 19:31 Ok, and which algo can answer on this question? A my idea. We should find answer for the first contestant. a[i] b[i] c[i] - is the speeds. x y z - the lengths. Write inequation describing that first contestant will win over i-th: (1/a[1] - 1/a[i])x + (1/b[1] - 1/b[i])y + (1/c[1] - 1/c[i])z < 0 Then, we should answer: are exist such x, y and z, that satisfy this inequations for each i > 1? | | why wa | Ras Misha [t4ce] | 1084. Goat in the Garden | 24 Nov 2007 16:42 | 5 | why wa Ras Misha [t4ce] 7 Dec 2006 19:02 it's my code: ------------------------------ {deleted} ------------------------------ Edited by author 09.12.2006 21:18 #include<iostream> #include<math.h> int main() { using namespace std;
long j=1,k,R,L; double s,pi=3.1415926535; cin>>L>>R; if(L>=2*R) s=pi*R*R; else if (R>(L*sqrt(2.0))/2) s=L*L; else s=2*R*R*atan((L*L-2*R*R)/(L*sqrt((double) 4*R*R-L*L)))+L*sqrt((double) 4*R*R-L*L);
k=s;
while(k>10) { k=k/10; j++; } cout.precision( 3+j ); cout << noshowpoint << s << endl;
return 0; } Помоги мне . . . Edited by author 10.12.2006 01:07 AC!!! And IV (ucs-usty-forever) 15 Apr 2007 01:56 program _1084; {$APPTYPE CONSOLE} uses SysUtils,math; const pi=3.1415926535; Var x,l,s,c:real; begin Readln(x,l); X:=x/2; c:=x*sqrt(2); if l>=c then s:=4*x*x; if l<=x then s:=pi*l*l; if not((l>=c)or(l<=x)) then Begin s:=8*(x*sqrt(l*l-x*x)/2+l*l/2*(pi/4-arccos(x/l))) end; writeln(s:0:3); end. program _1084; {$APPTYPE CONSOLE} uses crt; const pi=3.1415926535; Var x,l,s,c:real; begin Readln(x,l); X:=x/2; c:=x*sqrt(2); if l>=c then s:=4*x*x; if l<=x then s:=pi*l*l; if not((l>=c)or(l<=x)) then Begin s:=8*(x*sqrt(l*l-x*x)/2+l*l/2*(pi/4-arccos(x/l))) end; writeln(s:0:3); end. Edited by author 24.11.2007 16:45 Edited by author 24.11.2007 16:45 | | Why my program was got WA | TATUUF | 1008. Image Encoding | 24 Nov 2007 10:55 | 1 | My program is giving correct answers. But always I got WA1. If you know please help me. There is my code program ImageEncoding1; {$APPTYPE CONSOLE} uses SysUtils; var a:array[0..11,0..11]of boolean; x,y:array[0..11]of integer; f:boolean; i,n,x1,y1,k,code,j:integer; sn,s:string; begin assign(input,'in.txt'); assign(output,'out.txt'); reset(input); rewrite(output); readln(sn);f:=true; //readln(s); if(length(sn)<>3)then begin val(sn,n,code); for i:=1 to n do begin readln(y1,x1); if(f)then begin x[1]:=x1;y[1]:=y1;f:=false;end; a[y1,x1]:=true; end; k:=1;i:=1;writeln(y[1],' ',x[1]);a[y[1],x[1]]:=false; while i<=k do begin if(a[y[i]+1,x[i]])then begin k:=k+1;y[k]:=y[i]+1;x[k]:=x[i]; a[y[i]+1,x[i]]:=false;write('R');end; if(a[y[i],x[i]+1])then begin k:=k+1;y[k]:=y[i]; x[k]:=x[i]+1;a[y[i],x[i]+1]:=false;write('T');end; if(a[y[i]-1,x[i]])then begin k:=k+1;y[k]:=y[i]-1;x[k]:=x[i]; a[y[i]-1,x[i]]:=false;write('L');end; if(a[y[i],x[i]-1])then begin k:=k+1;y[k]:=y[i]; x[k]:=x[i]-1;a[y[i],x[i]-1]:=false;write('B');end; i:=i+1; if(k<i)then write('.')else writeln(','); end; end else begin val(copy(sn,1,1),y[1],code); val(copy(sn,3,1),x[1],code);k:=1;a[y[1],x[1]]:=true;j:=1; while(not eof)do begin readln(s); if(s='.')then break; n:=length(s); for i:=1 to n-1 do begin if(s[i]='B')then begin k:=k+1;y[k]:=y[j]; x[k]:=x[j]-1;a[y[k],x[k]]:=true;end else if(s[i]='T')then begin k:=k+1;y[k]:=y[j]; x[k]:=x[j]+1;a[y[k],x[k]]:=true;end else if(s[i]='R')then begin k:=k+1;y[k]:=y[j]+1;x[k]:=x[j]; a[y[k],x[k]]:=true;end else begin k:=k+1;y[k]:=y[j]-1;x[k]:=x[j]; a[y[k],x[k]]:=true;end; end; j:=j+1; end; writeln(k); for i:=0 to 11 do for j:=0 to 11 do if(a[i,j])then writeln(i,' ',j); end; end. Edited by author 29.12.2012 20:54 | | help!!why my programme is wrong!i find no mistake in it! | olive | 1005. Stone Pile | 24 Nov 2007 02:21 | 6 | #include<stdio.h> int main(){ int stonenumber; int i,j; long int s=0,t=0,a[20],u,minweight; scanf("%d",&stonenumber); for(i=0;i<stonenumber;i++) scanf("%d",&a[i]); for(j=0;j<stonenumber-1;j++) for(i=0;i<stonenumber-j-1;i++) if(a[i]>a[i+1]) {u=a[i];a[i]=a[i+1];a[i+1]=u;} s=a[stonenumber-1]; t=a[stonenumber-2]; for(i=stonenumber-3;i>=0;i--) if(t<s||t==s) t=t+a[i]; else s=s+a[i]; if(s>t) minweight=s-t; else minweight=t-s; printf("%d",minweight); return 0; } please reply me:287662136@163.com Edited by author 05.05.2005 09:07 Edited by author 05.05.2005 09:07 5 2000 3 4 5 6 The correct answer should be 1988,and what's your answer? how can be the correct answer 1988 if we put one stone 2000 in then one heap and other stones (3+4+5+6=18) in then second heap? 2000-18=1982 not a 1988 yeah, my answer is 1982, but I have wrong answer on test 1 Can you explain your solution? I'm struck with test 5! try this test: 5 3 3 2 2 2 the correct answer is 0. your program gives 2. Edited by author 24.11.2007 02:22 | | Begginers should try from which book of problems?? | Nashid | | 23 Nov 2007 12:54 | 2 | As I am a begginer I want to try from the easier problems. which volume of problems should I try first to solve??? Try to solve problems, witch were solved by a lot of people! Also you can solve problems from school contests (you can find them in contests archive) | | Help me! I have wa 1((( | Denis | 1392. Dreaming of Stars | 23 Nov 2007 00:04 | 1 | #include <iostream> #include <fstream> #include <stdio.h> #include <string> #include <algorithm> using namespace std; class sset { public: int p, rank; }; sset a[1010]; void init (int n) { int i; for (i = 0; i < n; ++i) { a[i].p = i; a[i].rank = 0; } } int fset (int x) { if (x != a[x].p) { a[x].p = fset (a[x].p); } return a[x].p; } void sset_union (int x, int y) { if (a[x].rank < a[y].rank) { a[x].p = a[y].p; } else { a[y].p = a[x].p; if (a[x].rank == a[y].rank) { a[x].rank++; } } } int n; string v[1010]; int c[1010][4] = {0}; int arr[1010] = {0}; bool is_in (int i, int j) { int cd; cd = (c[i][0]-c[j][0])*(c[i][0]-c[j][0]) + (c[i][1]-c[j][1])*(c[i][1]-c[j][1]) + (c[i][2]-c[j][2])*(c[i][2]-c[j][2]); int rd = c[i][3]+c[j][3]; rd *= rd; return rd > cd; } int main () { //freopen ("a.in", "r", stdin); //freopen ("a.out", "w", stdout); int i, j; int di; int p, q; scanf ("%d", &n); init (n); for (i = 0; i < n; ++i) { scanf ("%d%d%d%d", &c[i][0], &c[i][1], &c[i][2], &c[i][3]); di = -1; for (j = i-1; j >= 0; --j) { if (is_in(i, j)) { p = fset (i); q = fset (j); sset_union (p, q); } } } for (i = 0; i < n; ++i) { j = fset(i); if (v[j] == "") { v[j] = (char)(i+'0'); } else { v[j] += ", "; v[j] += (char)(i+'0'); } } sort (v, v+n); for (i = 0; i < n; ++i) { if (v[i] != "") { cout<<v[i]<<endl; } } return 0; } | | please give me a test, I have WA 15 =) | Samsonov Ivan (Rybinsk SAAT) | 1246. Tethered Dog | 22 Nov 2007 21:53 | 3 | #include <iostream> using namespace std; int main() { int N,z=0,z1,z2; int x1,y1,x2,y2,x3,y3; cin >> N >> x1 >> y1 >> x2 >> y2; N-=2; int xx1=x1,yy1=y1; x1 =x2 - x1; y1 =y2 - y1; int xx=x1,yy=y1; while (N--) { cin >> x3 >> y3; z1 =x3 - x2; z2 =y3 - y2; z+= x1*z2-z1*y1; x1 = z1; y1 = z2; x2 = x3; y2 = y3; } z1 = xx1-x3; z2 = yy1-y3; z+= z1*yy-z2*xx; if (z<0) cout << "cw"; else cout << "ccw"; return 0; } Edited by author 24.08.2007 15:33 I think you've forgotten about the 1st and nth points) And also you should write something like z += ... to count the total direction) Good Luck!)) Edited by author 24.08.2007 08:57 I had the same problem. But when I replaced "int" with "double", I've got AC. Just try to calculate next expression: 50000*50000 - 50000*(-50000) = ??????????? | | How can i do faster? | Yashar Abbasov | 1189. Pairs of Integers | 22 Nov 2007 14:37 | 1 | | | C/C++ Compiler switches changed (+) | Vladimir Yakovlev (USU) | | 21 Nov 2007 23:35 | 1 | Switch /O1 was added to command line of C/C++ compiler. This switch is used instead of default /O2 switch. Description from compiler help: /O1 optimize for maximum speed, but disable some optimizations which increase code size for a small speed benefit /O2 optimize for maximum speed (DEFAULT) ICL compiler sometimes makes wrong code with /O2 switch. To prevent wrong verdicts we have changed switches but loose some performance. Some programs will work a little bit slower now. Current compiler's command line: // C icl /GX /TC /Za /O1 /D ONLINE_JUDGE // C++ icl /GX /TP /Za /O1 /D ONLINE_JUDGE (See http://acm.timus.ru/help.aspx?topic=cpp ) Edited by author 21.11.2007 23:39 | | WA14??? | naTural | 1295. Crazy Notions | 21 Nov 2007 11:18 | 1 | can someone give me tests to compile my programm? | | what the answer | TonAC119 | 1244. Gentlemen | 21 Nov 2007 10:07 | 4 | -1 Edited by author 03.01.2008 14:22 | | Why Wrong answer(Pascal) | Sasha | 1001. Reverse Root | 21 Nov 2007 00:22 | 2 | program BackSQRT; {$APPTYPE CONSOLE} uses SysUtils; var f,fout: Text; a:array[0..99999999] of extended; tmp: int64; count,j: 0..99999999; begin Count:=0; assignfile(f,'input.txt'); reset(f); while not Eof(f) do begin while not Eoln(f) do begin read(f,tmp); if tmp<0 then continue; a[count]:=tmp; inc(count); // -1 end; readln(f); end; closefile(f); assignfile(fout,'out.txt'); rewrite(fout); for j:=count-1 downto 0 do writeln(fout,sqrt(a[j]):0:4); closefile(fout); end. use standart input and output stream... | | Why my program work so slow? | Roma Labish[Lviv NU] | 1249. Ancient Necropolis | 20 Nov 2007 20:24 | 4 | I've only read and check, and don't read whole input. Why it work's less then 4 sek? [code deleted] Edited by author 26.01.2007 17:17 Use scanf instead of cin Input file is very big >10MB but better use Pascal:) I don't optimize input at all. It works about 1.3 sec After simple optimization 0.328 sec Edited by author 26.01.2007 16:15 Thank you! I've changed cin to scanf and got AC in 1.5 sec )) Try to use "gets()" instead "scanf()" and "cin". You can solve it with 2 strings (length = 2*m + 2). I've get AC at 0.156 sec. And some solution are faster. | | WA 4 | Backs | 1571. Interpreters | 20 Nov 2007 19:38 | 2 | WA 4 Backs 1 Nov 2007 14:51 why WA on test 4? what answer on test: input.txt 2 a b ??? | | Who can help me with the 4th test? | terro | 1189. Pairs of Integers | 20 Nov 2007 17:44 | 1 | Wrong Answer with test 4. I don't know what happened. So who can help me with it? | | I get WA on test 7. Could someone give me any hint? | tantian | 1041. Nikifor | 20 Nov 2007 16:33 | 2 | program ex; const maxn=2000; maxm=50; zero=1e-15; var g: Array[0..maxn, 1..maxm] of extended; cost: Array[1..maxn] of longint; from: Array[1..maxn] of longint; n, m: longint; ans: longint; num: Array[1..maxm] of longint; tot: longint; kk: Array[1..maxn] of longint; procedure init; var i, j: longint; begin read(n, m); for i:=1 to n do for j:=1 to m do read(g[i, j]); for i:=1 to n do begin read(cost[i]); from[i]:=i; end; end; procedure qsort(l, r: longint); var i, j: longint; x, y: longint; t: longint; begin i:=l; j:=r; x:=cost[(l+r) shr 1]; y:=from[(l+r) shr 1]; while i<=j do begin while (cost[i]<x)or(cost[i]=x)and(from[i]<y) do inc(i); while (cost[j]>x)or(cost[j]=x)and(from[j]>y) do dec(j); if i<=j then begin g[0]:=g[i]; g[i]:=g[j]; g[j]:=g[0]; t:=cost[i]; cost[i]:=cost[j]; cost[j]:=t; t:=from[i]; from[i]:=from[j]; from[j]:=t; inc(i); dec(j); end; end; if j>l then qsort(l, j); if i<r then qsort(i, t); end; function can(x: longint): boolean; var i, j: longint; len1, len2: extended; sum: extended; co: extended; tt: extended; temp: Array[1..maxn] of extended; begin for i:=1 to tot do begin sum:=0; len1:=0; len2:=0; for j:=1 to m do begin sum:=sum+g[x, j]*g[i, j]; len1:=len1+g[x, j]*g[x, j]; len2:=len2+g[kk[i], j]*g[kk[i], j]; end; len1:=sqrt(len1); len2:=sqrt(len2); if abs(len1)<=zero then exit(false); co:=sum/len1/len2; tt:=len1*co; for j:=1 to m do temp[j]:=g[kk[i], j]*tt/len2; for j:=1 to m do g[x, j]:=g[x, j]-temp[j]; end; for j:=1 to m do if abs(g[x, j])>zero then exit(true); exit(false); end; procedure solve; var i: longint; begin qsort(1, n); tot:=1; num[1]:=from[1]; ans:=ans+cost[1]; kk[1]:=1; for i:=2 to n do if can(i) then begin inc(tot); kk[tot]:=i; num[tot]:=from[i]; ans:=ans+cost[i]; if tot=m then exit; end; end; procedure print; var i, j: longint; t: longint; begin if tot<m then writeln(0) else begin writeln(ans); for i:=1 to m do for j:=i+1 to m do if num[i]>num[j] then begin t:=num[i]; num[i]:=num[j]; num[j]:=t; end; for i:=1 to m do writeln(num[i]); end; end; begin init; solve; print; end. | | Please,Help Me!!!! I have WA#1 on C++!Thank you Very much!!!!!! I Really need your help!!!Here is my code: | CHIDEMYAN SERGEY | 1446. Sorting Hat | 20 Nov 2007 01:22 | 3 | OH,I find my mistake!!! Edited by author 05.05.2007 16:28 can you tell me what the mistake is. coz im also getting WA in test#1 itself Solved. Well, i'd given an endl before even printing the results.:( | | Please HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | BAron | 1132. Square Root | 20 Nov 2007 01:21 | 3 | Give me a few tests, please! Anybody, who had WA1 and then had AC, please help me!!!!!!!! Tests or any hints, please!!!!!!! Edited by author 24.06.2007 19:23 | | AC 0.001s 120 k | Bourne | 1297. Palindrome | 19 Nov 2007 15:47 | 2 | program Bourne; var x:char; a:array[1..1000] of char; n,i,start,len,maxlen:integer; procedure find(p,q:integer); var p0,q0:integer; begin p0:=p; q0:=q; while (p0>=1)and(q0<=n)and(a[p0]=a[q0]) do begin inc(len,2); inc(q0); dec(p0); end; if len>maxlen then begin maxlen:=len; start:=p0; end; end; begin n:=0; repeat read(x); inc(n); a[n]:=x; until eoln; maxlen:=0; for i:=1 to n do begin len:=0; find(i,i+1); len:=1; find(i-1,i+1); end; for i:=1 to maxlen do write(a[start+i]); writeln; end. I used DP O(n^2) var st : ansistring; f : array [0..1010,0..1010] of boolean; i,j,cx,cy,max : longint; begin readln(st); max:=0; for i:=1 to length(st) do for j:=1 to i do f[i,j]:=true; for i:=1 to length(st)-1 do for j:=1 to length(st)-i do if st[j] = st[i+j] then f[j,i+j]:=f[j+1,i+j-1] else f[j,i+j]:=false; max:=-1; for i:=1 to length(st) do for j:=0 to length(st)-i do if (f[i,i+j]) and (j>max) then begin cx:=i; cy:=i+j; max:=j; end; for i:=cx to cy do write(st[i]); writeln; end. | | Any Hint? | Jordan | 1180. Stone Game | 18 Nov 2007 22:49 | 4 | |
|
|