Common Board| Show all threads Hide all threads Show all messages Hide all messages | | Why I got WA on test#2 | Pluto | 1049. Brave Balloonists | 14 Aug 2007 12:29 | 2 | Please tell me the input and the right answer. I didn't find where my code was wrong. Thanks. | | TO ADMINS | Al.Cash | | 14 Aug 2007 11:46 | 2 | I have some test for rejudging Problem 1166! Where can I send them? And if you answer me how can I know that you are really admins? | | program | saba | 1022. Genealogical Tree | 14 Aug 2007 09:55 | 2 | I want c++ program which gives AC Edited by author 02.06.2007 20:02 #include <iostream> #include <vector> #include <set> using namespace std; int main() { int i, k, n; cin >> n; vector< set<int> > out(n), in(n); for (i=0;i<n;i++) while (cin>>k, k) { out[i].insert(--k); in[k].insert(i); } set<int> q; for (i=0;i<n;i++) if (in[i].empty()) q.insert(i); vector<int> top; while (!q.empty()) { top.push_back(k=*q.begin()); q.erase(q.begin()); for (set<int>::iterator it=out[k].begin();it!=out[k].end();++it) { i=*it; in[i].erase(k); if (in[i].empty()) q.insert(i); } } cout << top[0]+1; for (i=1;i<n;i++) cout << ' ' << top[i]+1; return 0; } | | WA#9 Z-Algo | ZuTa | 1423. String Tale | 13 Aug 2007 21:34 | 1 | I don't understand why my program wrong I wrote Z-Algorithm. I give my program max-tests and answers were correct. Please give me some hints or tests/ Thanks | | Please Help Me! I have WA#1! | Kurpilyansky Eugene (USU) | 1231. Turing: One, Two, Three, … | 13 Aug 2007 20:39 | 1 | for k=2 this program is correct, isn't it? 38 1 - 1 - < 1 # 11 A > 2 + 2 + < 2 - 3 - > 2 A 4 A > 3 - 13 - = 3 + 3 + > 4 + 4 + > 4 - 5 - > 5 + 5 + > 5 - 6 - < 5 # 7 # < 6 + 6 + < 6 - 13 - = 7 + 7 + < 7 - 8 - < 8 + 8 + < 8 A 9 # > 9 + 9 + > 9 - 10 - = 11 - 2 - < 11 + 11 + > 11 # 12 # < 12 - 12 - < 12 + 12 + < 12 A 11 A > 13 + 13 + > 13 - 14 - > 13 # 15 # < 14 + 14 + > 14 - 11 + = 14 # 16 # < 15 - 15 - < 15 + 15 + < 15 A 13 A > 16 - 16 - < 16 + 16 + < 16 A 14 A > | | A useful test for Test #8 | xcheng | 1116. Piecewise Constant Function | 13 Aug 2007 10:31 | 1 | 1 1 5 3 2 1 2 5 3 4 5 The output is obvious. - - | | please help.. why I have compilation error?? | Felipe Guilhon | 1073. Square Country | 12 Aug 2007 16:50 | 2 | the only part that I can think of getting compile error is this: int num; int tmp; tmp = (int) sqrt(num); But why?? Write tmp = (int) sqrt((double)num)(p.s. read FAQ) | | I got WA on test 12, but I pass all test in discuss? | tantian | 1074. Very Short Problem | 12 Aug 2007 09:18 | 2 | Could anyone help me? Please send the test 12 to my email. ttxxli@163.com | | Please, tell me, why? ... :( | Anton Silin (YarSU) | 1001. Reverse Root | 12 Aug 2007 03:22 | 2 | This code gives crash on 7 test, I don't know, why... #include <iostream.h> #include <stdio.h> #include <math.h> int i; void main() { double M[8000]; double t; int n=0; while ( cin >> t ) { M[n] = sqrt( t ); n++; } for( int i=n-1; i>=0; i--) { printf("%.4f\n", M[i] ) ; } } Can you give any idea, why is it so? 8000 don't enough.Put attention there:Размер входного потока не превышает 256 КБ. If you write double *M=new double[8000000](i.e.creating dynamic array) instead of double M[8000] I'm think you will get AC.Good luck! Edited by author 12.08.2007 03:29 | | I have WA1, here is my code, help me, please! | [SPbSU ITMO] Dennis Yolkin | 1127. Colored Bricks | 12 Aug 2007 03:13 | 3 | I used dynamic programming for solving this problem, on the sample test program's output is correct, I have WA1 and do not know, were is the bug. Help me, please! import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Solution implements Runnable {
BufferedReader in; PrintWriter out; StringTokenizer strtok;
int nextInt() throws Exception { while (strtok == null || !strtok.hasMoreTokens()) { strtok = new StringTokenizer(in.readLine()); } return Integer.parseInt(strtok.nextToken()); } int n; int[][] d; String[] c; int[][] pos = {{0, 1, 3, 2, 4, 5}, // stay on bottom {0, 4, 3, 5, 1, 2}, // stay on left {5, 1, 4, 2, 3, 0}};
boolean match(int c1, int pos1, int c2, int pos2) { char[] s1 = new char[6], s2 = new char[6]; for (int i = 0; i < 6; ++i) { s1[i] = c[c1].charAt(pos[pos1][i]); s2[i] = c[c2].charAt(pos[pos2][i]); }
boolean ok1, ok2; for (int shift = 0; shift < 4; ++shift) { ok1 = true; ok2 = true; for (int i = 0; i < 4; ++i) { if (s1[i] != s2[(i + shift) % 4]) { ok1 = false; break; } } for (int i = 0; i < 4; ++i) { if (s1[3 - i] != s2[(i + shift) % 4]) { ok2 = false; break; } } if (ok1 || ok2) { return true; } } return false; }
void solve() { d = new int[pos.length][n]; for (int curbox = 0; curbox < n; ++curbox) { for (int curpos = 0; curpos < pos.length; ++curpos) { d[curpos][curbox] = 1; for (int prevbox = 0; prevbox < curbox; ++prevbox) { for (int prevpos = 0; prevpos < pos.length; ++prevpos) { if (match(prevbox, prevpos, curbox, curpos)) { d[curpos][curbox] = Math.max(d[curpos][curbox], d[prevpos][prevbox] + 1); } } } } } }
void outputDP() { for (int i = 0; i < pos.length; ++i) { for (int j = 0; j < n; ++j) { out.printf("%d ", d[i][j]); } out.println(); } }
public void run() { try { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out);
n = nextInt(); c = new String[n]; for (int i = 0; i < n; ++i) { c[i] = in.readLine(); } solve(); //outputDP();
int max = 0; for (int i = 0; i < pos.length; ++i) { max = Math.max(d[i][n - 1], max); } out.println(max);
/*c = new String[2]; c[0] = in.readLine(); int aa = nextInt(); c[1] = in.readLine(); int bb = nextInt(); out.println(match(0, aa, 1, bb));*/
} catch (Exception er) { er.printStackTrace(); System.exit(13); } finally { out.close(); } }
public static void main(String[] args) { new Thread(new Solution()).start(); } }
>I have WA1 and do not know, were is the bug That was Timus bug. Old test#1 had a brick with 2 sides of the same color. Now test#1 is a sample test. You have TL now. | | How can I detect the end of the entry stream? | Anton Silin (YarSU) | 1001. Reverse Root | 12 Aug 2007 01:11 | 2 | How can I detect the end of the entry stream? Some people use "while(cin>>n)" So, could you explain, what does it mean? All right, I see the idea:) | | TO ADMINS | panyong0202 | 1455. Freedom of Speech | 11 Aug 2007 08:54 | 1 | I think there are some bugs in my solution, but I got AC! | | Yeah,at last I've AC!!! | CHIDEMYAN SERGEY | 1350. Canteen | 11 Aug 2007 02:52 | 1 | Edited by author 18.08.2007 13:58 Edited by author 18.08.2007 14:50 | | Is the k must smaller than n? | tantian | 1268. Little Chu | 10 Aug 2007 06:25 | 4 | 3 Can the answer be 5 or bigger? Edited by author 09.08.2007 06:10 Edited by author 09.08.2007 06:10 "he can’t sleep more than one week after his birth" Yes k < n | | sorry,if anybody can,please explain me the task!!!thank!! | CHIDEMYAN SERGEY | 1350. Canteen | 10 Aug 2007 02:56 | 5 | Edited by author 03.05.2007 22:12 Edited by author 03.05.2007 22:14 Edited by author 10.08.2007 02:54 Edited by author 10.08.2007 02:57 Edited by author 18.08.2007 14:51 IF you can,write me on serchch@mail.ru. Thank!!! Edited by author 03.05.2007 22:13 Edited by author 10.08.2007 02:57 Edited by author 18.08.2007 14:51 | | Crash | mj256 | 1165. Subnumber | 9 Aug 2007 11:21 | 1 | Crash mj256 9 Aug 2007 11:21 I think I've passed all the tests ther user TEST sent here, but I always get Crash(access violation). Could you tell me why? program p1005; type number=record n:array[1..300]of integer; nk:integer; end; var a,s,t:string; f:array[1..200]of number; ansk,i,j,st,p,long:integer; final,ans:number; d1:boolean; function combine(x,y:string):string; var i:integer; begin for i:=length(x) downto 1 do if copy(x,length(x)-i+1,i)=copy(y,1,i) then begin x:=x+copy(y,i+1,length(y)-i); exit(x); end; exit(x+y); end; function next(ts:string):string; var i:integer; begin i:=length(ts); ts[i]:=succ(ts[i]); while (ts[i]=':')and(i>0) do begin ts[i]:='0'; ts[i-1]:=succ(ts[i-1]); dec(i); end; if i=0 then begin ts:='1'+ts;ts:=copy(ts,1,length(ts)-1);end; exit(ts); end; function check(st:integer;a:string):boolean; var ts:string; watch,k,now:integer; back:boolean; begin back:=false; if st<>1 then begin ts:=copy(s,1,st-1); k:=length(ts); if (ts[1]='0')and(abs(length(ts)-length(a))<1) then exit(false); ts:=next(ts); if copy(a,1+length(a)-k,k)<>copy(ts,length(ts)-k+1,k) then exit(false); end; now:=st; ts:=a; while now+length(ts)-1-ord(back)<=length(s) do begin if copy(s,now,length(ts))<>ts then exit(false); now:=now+length(ts); ts:=next(ts); end; if now>length(s) then exit(true); if copy(s,now,length(s)-now+1)<>copy(ts,1,length(s)-now+1) then exit(false); exit(true); end; function plus(a,b:number):number; var i,j,t:integer; c:number; begin if a.nk>b.nk then j:=a.nk else j:=b.nk; t:=0;fillchar(c,sizeof(c),0); for i:=1 to j do begin c.n[i+1]:=(a.n[i]+b.n[i]+c.n[i])div 10; c.n[i]:=(c.n[i]+a.n[i]+b.n[i])mod 10; end; if c.n[j+1]<>0 then inc(j); c.nk:=j; exit(c); end; procedure makef; var temp:number; i,j:integer; begin f[1].nk:=1; f[1].n[1]:=9; for i:=2 to length(a)-1 do begin fillchar(temp,sizeof(temp),0); j:=9*i; temp.n[i]:=j;j:=i; while temp.n[j]>10 do begin temp.n[j+1]:=temp.n[j] div 10; temp.n[j]:=temp.n[j] mod 10; inc(j); end; temp.nk:=j; f[i]:=plus(f[i-1],temp); end; end; procedure makeans; var k,l,i,j:integer; temp:number; begin fillchar(ans,sizeof(ans),0); ans:=plus(ans,f[length(a)-1]); l:=length(a); {i:=ord(a[1])-49; if i<>0 then begin fillchar(temp,sizeof(temp),0); temp.n[l]:=i*l;i:=l; while temp.n[i]>=10 do begin temp.n[i+1]:=temp.n[i] div 10; temp.n[i]:=temp.n[i] mod 10; inc(i); end; temp.nk:=i; ans:=plus(ans,temp); end;} for k:=1 to l do begin i:=ord(a[k])-48;if k=1 then dec(i);if k=l then inc(i); fillchar(temp,sizeof(temp),0); temp.n[l-k+1]:=i*l;i:=l-k+1; while temp.n[i]>10 do begin temp.n[i+1]:=temp.n[i] div 10; temp.n[i]:=temp.n[i] mod 10; inc(i); end; temp.nk:=i; ans:=plus(ans,temp); end; end; function minus(a,b:number):number; var i,j:Integer; c:number; begin fillchar(c,sizeof(c),0); for i:=1 to a.nk do begin c.n[i]:=c.n[i]+a.n[i]-b.n[i]; if c.n[i]<0 then begin inc(c.n[i],10); dec(c.n[i+1]); end; end; if a.n[a.nk]=0 then c.nk:=a.nk-1 else c.nk:=a.nk; exit(c); end; procedure print; var i,j:integer; temp:number; begin i:=0; while p>0 do begin inc(i); temp.n[i]:=p mod 10; p:=p div 10; end; temp.nk:=i; ans:=minus(ans,temp); if ans.nk<final.nk then final:=ans; if ans.nk=final.nk then begin i:=ans.nk; while ans.n[i]=final.n[i] do dec(i); if ans.n[i]<final.n[i] then final:=ans; end; end; begin
final.nk:=1000; readln(s); for long:=1 to length(s) do for st:=1 to length(s)-long+1 do begin a:=(copy(s,st,long)); if (check(st,a))and(a[1]<>'0') then begin makef; makeans; p:=st+long-2; print; end; if st<>length(s)-long+1 then continue; t:=next(copy(s,1,st-1)); t:=copy(t,length(t)-st+2,st-1); a:=combine(a,t); if (check(st,a))and(a[1]<>'0') then begin makef; makeans; p:=st+length(a)-2; print; end; end; a:='1'+s; makef; makeans; p:=length(s)-1; print; for i:=final.nk downto 1 do write(final.n[i]); writeln; end. | | What does this problem mean? | tantian | 1358. Cables | 9 Aug 2007 07:54 | 1 | What's the task? Could you help me? | | What outputs is correct? | Kurpilyansky Eugene (USU) | 1345. HTML | 9 Aug 2007 00:23 | 2 | input1 begin end. output1 <span class=keyword>begin</span> <span class=keyword>end</span>. or <span class=keyword>begin end</span>. input2 'as as' output2 <span class=string>'as</span> as'</span> or <span class=string>'as</span> as<span class=string>'</span> input3 1. outpu3 <span class=number>1</span>. or <span class=number>1.</span> Edited by author 23.01.2007 21:12 1 <span class=keyword>begin</span> <span class=keyword>end</span>. 2 <span class=string>'as as'</span> 3 <span class=number>1</span>. | | WA#8 | Grosu Andrei | 1062. Triathlon | 8 Aug 2007 21:36 | 1 | WA#8 Grosu Andrei 8 Aug 2007 21:36 I write a program of only 50 lines that solves this problem, but i get WA at test nr.8. Can someone tell me what is in test 8? i have no idea. thanks. | | can you help?? | timus_bottle | 1001. Reverse Root | 8 Aug 2007 02:06 | 2 | #include <cstdio> #include <cmath> #include <iostream> using namespace std; int main() { double ssqrt[4370],n; int i=0; while(cin>>n) { ssqrt[i]=sqrt(n); i++; } for(i-=1;i>=0;i--) printf("%.4f\n",ssqrt[i]); return 0; } Why 4370? ;) And how I see, you have "Crash (access violation)". It's problem of sizes. I thing you must thing in this way. Good Luck! |
|
|