Show all threads Hide all threads Show all messages Hide all messages | WA on test 3 | Constantin Stefan | 1186. Chemical Reactions | 5 Oct 2015 01:21 | 1 | Can you give me more tests so i can check my programm? Any input i give him is solved correctly, no matter the size or the number of paranthesis. Please help! | To admins | Глащенко Никита | 1186. Chemical Reactions | 14 Aug 2009 16:34 | 3 | My AC program gives wrong answer on test 4C 1 (C(C))2 formulas are equal, but my program doesn't agree with me. <formula> ::= <sequence> // <sequence> <sequence> ::= <element><number> // <element><number> <number> ::= 2 // <element>2 <element> ::= '(' <sequence> ')' // (<sequence>)2 <sequence> ::= <element><element> // (<element><element>)2 <element> ::= C // (C<element>)2 <element> ::= '(' <sequence> ')' // (C(<sequence>))2 <sequence> ::= C // (C(C))2 Without some obvious steps. Am I wrong? | I need more tests | armud | 1186. Chemical Reactions | 18 Sep 2008 22:15 | 3 | I have WA#3. Can you give more tests, please? Otherwise I couldn't find my mistake CO2 1 (O)2C Answer is: CO2==(O)2C This one helped me alot: 6C 12 6C C6 ((((C)6))) ((C3)2) 2C3 CCCCCC C2C3C 2CC2 C+C+C+C+C+C (C)+(C)+(C)+(C)+(C)+(C) (C)(C)(C)(C)(C)(C) 2(C(C))+(C)(C) All the answers the same '=='. | For All Who Got Wa1 or Other on Pascal. | ACM.Tolstobrov_Anatoliy[Ivanovo SPU] | 1186. Chemical Reactions | 5 Feb 2006 16:54 | 1 | Add This Function And You Maybe Got AC. Function Copy(S:String;St,En:LongInt):String; Var Ans:String; i:LongInt; Begin Ans:=''; For i:=St To En Do Ans:=Ans+S[i]; Copy:=Ans; End; Good Luck & Have Fun | WA on #1, where am I wrong? | Danica Porobic | 1186. Chemical Reactions | 1 Jul 2004 18:18 | 1 | type TArray=array[1..1000] of integer; var code:array[1..1000] of string; num,temp:TArray; i,n,nc:integer; s,t:string; function match(a,b:TArray):Boolean; var i:integer; ok:Boolean; begin ok:=true; for i:=1 to nc do ok:=ok and (a[i]=b[i]); match:=ok end; procedure init(var a:TArray); begin fillchar(a,sizeof(a),0) end; function decode(s:string):integer; var i:integer; begin i:=0; repeat inc(i) until (i=nc+1) or (s=code[i]); if i=nc+1 then begin inc(nc); code[nc]:=s end; decode:=i end; procedure analyze(s:string;var a:TArray); var i,mul,count:integer; sp,c:string; begin init(a); repeat if pos('+',s)>0 then begin sp:=copy(s,1,pos('+',s)-1); delete(s,1,pos('+',s)) end else begin sp:=s; s:='' end; mul:=0; i:=1; while ('0'<=sp[i]) and (sp[i]<='9') do begin mul:=10*mul+ord(sp[i])-ord('0'); inc(i) end; if mul=0 then mul:=1; while i<=length(sp) do begin if (sp[i]='(') or (sp[i]=')') then inc(i) else if ('A'<=sp[i]) and (sp[i]<='Z') then begin c:=sp[i]; inc(i); if ('a'<=sp[i]) and (sp[i]<='z') then begin c:=c+sp[i]; inc(i) end; while (sp[i]='(') or (sp[i]=')') do inc(i); count:=0; while ('0'<=sp[i]) and (sp[i]<='9') do begin count:=10*count+ord(sp[i])-ord('0'); inc(i) end; if count=0 then count:=1; a[decode(c)]:=a[decode(c)]+mul*count end end until s=''; end; begin assign(input,''); reset(input); readln(s); nc:=0; analyze(s,num); readln(n); for i:=1 to n do begin readln(t); analyze(t,temp); if match(num,temp) then writeln(s,'==',t) else writeln(s,'!=',t) end; close(input); end. | Why I get wrong? | sunshine | 1186. Chemical Reactions | 8 Sep 2002 13:14 | 2 | I did it like this: Why I get wrong? type td=array[1..26,0..26]of integer; tt=record a,b:integer; x:array[1..2]of integer; xi:integer; ty:integer; d:td; end; var s1,s2:string; i,n:integer; d1,d2:td; t:array[1..50]of ^tt; procedure turn(s:string;var d:td); var i,o,p:integer; k:integer; begin k:=1; new(t[k]); fillchar(t[k]^,sizeof(t[k]^),0); t[k]^.x[1]:=1; t[k]^.x[2]:=1; s:=s+'.'; for i:=1 to length(s) do begin with t[k]^ do begin if s[i] in ['(',')','.','A'..'Z','+'] then begin if ty=1 then d[a,b]:=d[a,b]+x[1]*x[2]; if ty=2 then begin for o:=1 to 26 do for p:=0 to 26 do d[o,p]:=d[o,p]+t[k+1]^.d[o,p]*x[2]*x[1]; dispose(t[k+1]); end; x[1]:=1; xi:=0; end; case s[i] of 'A'..'Z':begin ty:=1; a:=byte(s[i])-byte('A')+1; b:=0; end; 'a'..'z':begin b:=byte(s[i])-byte('a')+1; end; '0'..'9':begin if xi=0 then begin if a=0 then xi:=2 else xi:=1; x[xi]:=byte(s[i])-byte('0'); end else x[xi]:=x[xi]*10+byte(s[i])-byte('0'); end; '(':begin ty:=2; inc(k); new(t[k]); fillchar(t[k]^,sizeof(t[k]^),0); t[k]^.x[1]:=1; t[k]^.x[2]:=1; end; ')':begin dec(k); end; '+':begin a:=0; b:=0; x[1]:=1; x[2]:=1; xi:=0; ty:=0; end; end; end; end; delete(s,length(s),1); d:=t[k]^.d; end; function bj(var d1,d2:td):boolean; var i,j:integer; begin for i:=1 to 26 do for j:=0 to 26 do if d1[i,j]<>d2[i,j] then begin bj:=false; exit; end; bj:=true; end; begin readln(s1); turn(s1,d1); readln(n); for i:=1 to n do begin readln(s2); turn(s2,d2); if bj(d1,d2) then writeln(s1,'==',s2) else writeln(s1,'!=',s2) end; end. I don't know!!! > > type > td=array[1..26,0..26]of integer; > tt=record > a,b:integer; > x:array[1..2]of integer; > xi:integer; > ty:integer; > d:td; > end; > var > s1,s2:string; > i,n:integer; > d1,d2:td; > t:array[1..50]of ^tt; > procedure turn(s:string;var d:td); > var > i,o,p:integer; > k:integer; > begin > k:=1; > new(t[k]); > fillchar(t[k]^,sizeof(t[k]^),0); > t[k]^.x[1]:=1; > t[k]^.x[2]:=1; > s:=s+'.'; > for i:=1 to length(s) do > begin > with t[k]^ do > begin > if s[i] in ['(',')','.','A'..'Z','+'] then > begin > if ty=1 > then d[a,b]:=d[a,b]+x[1]*x[2]; > if ty=2 > then begin > for o:=1 to 26 do > for p:=0 to 26 do > d[o,p]:=d[o,p]+t[k+1]^.d[o,p]*x[2]*x[1]; > dispose(t[k+1]); > end; > x[1]:=1; > xi:=0; > end; > case s[i] of > 'A'..'Z':begin > ty:=1; > a:=byte(s[i])-byte('A')+1; > b:=0; > end; > 'a'..'z':begin > b:=byte(s[i])-byte('a')+1; > end; > '0'..'9':begin > if xi=0 then > begin > if a=0 > then xi:=2 > else xi:=1; > x[xi]:=byte(s[i])-byte('0'); > end > else x[xi]:=x[xi]*10+byte(s[i])-byte('0'); > end; > '(':begin > ty:=2; > inc(k); > new(t[k]); > fillchar(t[k]^,sizeof(t[k]^),0); > t[k]^.x[1]:=1; > t[k]^.x[2]:=1; > end; > ')':begin > dec(k); > end; > '+':begin > a:=0; > b:=0; > x[1]:=1; > x[2]:=1; > xi:=0; > ty:=0; > end; > end; > end; > end; > delete(s,length(s),1); > d:=t[k]^.d; > end; > function bj(var d1,d2:td):boolean; > var > i,j:integer; > begin > for i:=1 to 26 do > for j:=0 to 26 do > if d1[i,j]<>d2[i,j] then > begin > bj:=false; > exit; > end; > bj:=true; > end; > begin > readln(s1); > turn(s1,d1); > readln(n); > for i:=1 to n do > begin > readln(s2); > turn(s2,d2); > if bj(d1,d2) > then writeln(s1,'==',s2) > else writeln(s1,'!=',s2) > end; > end. |
|
|