Help! What is wrong? [code deleted] Edited by moderator 05.11.2023 02:38 maybe this test can halp you? 5 00000 01111 01111 01110 00000 I also had WA 16, turns out this was the reason: 5 11100 10000 00011 11000 00000 In this test, i assumed that you can move away parts with 1's, thus separating 0's from everything. But it turns out to be wrong, you're only allowed to move zeros, and ones stay fixed in place. 1)3 111 111 111 yes 2)3 111 101 111 no 3)5 11100 10000 00011 11000 00000 no 4)5 11111 00011 01111 00001 00111 yes Try these data: 7 0000000 0000000 0011111 0011111 0011111 0011111 0000111 5 00111 01111 01111 00000 00000 5 11000 10000 10000 10000 11000 5 00011 00001 00001 00011 00111 output: Yes Good luck! Try these tests: (1) - No 10001 11001 10011 11111 11111 (2) - Yes 100001 110001 111001 111011 111111 111111 (3) - Yes 111111 111010 111010 111010 111010 000000 Good luck! Edited by author 31.07.2010 19:34 now AC. Edited by author 15.10.2006 23:59 5 00000 01110 01110 01110 00000 No Edited by author 05.05.2009 14:15 It is not necessary a rectangle. Try 5 11111 11011 11011 10010 00000 Yes and all its rotations. BTW, to read you can use #define F(i,n) for(int i = 0; i < n; ++i) int n; vector<string> s; [...] cin >> n; s.resize(n, string(n,' ')); F(i,n) cin >> s[i]; and AC at 0.046 second. ... whereas F(i,n) { string str; cin >> str; s.push_back(str); } results in 0.109 seconds and 500 KB of wasted memory. 1. не отрывая ни один из кусков с поверхности стола -> не отрывая ни один из кусков от поверхности стола Комментарий: никогда не встречал выражения "отрывать с", обычно "отрывать от". 2. Выведете «Yes» -> Выведите «Yes» Комментарий: в олимпиадных задачах более традиционным является побуждение "выведите", чем предсказание "выведете". Edited by author 27.02.2008 00:00 Edited by author 27.02.2008 00:00 Is 1000000 of int is too much? I think it is about of 4 megabytes of RAM. If c=1000 its crashes. Why? Code is here: #include <iostream.h> #include <iostream> const long c=1001; int main() { // freopen("input.txt","rw",stdin); char ch; long i,j,n,fl,fl1,fl2,a[c][c],p1[c],q1[c],p2[c],q2[c]; i=j=n=fl=fl1=fl2=0; cin>>n; for (i=1;i<n+1;i++) for (j=1;j<n+1;j++) {cin.get(ch); if ((ch=='0')||(ch=='1')){a[i][j]=ch-'0';} else j--;} for (i=1;i<n+1;i++) { fl=0; for (j=1;j<n+1;j++) if (a[i][j]==0) fl=1; if (fl==1) q1[i]=0; else q1[i]=1; fl=0; for (j=1;j<n+1;j++) if (a[j][i]==0) fl=1; if (fl==1) q2[i]=0; else q2[i]=1; } for (i=1;i<n+1;i++){p1[i]=a[i][1];} for (i=1;i<n+1;i++){p2[i]=a[1][i];} fl1=1;fl2=1; for (i=1;i<n+1;i++) if ((q1[i]==0)&(p1[i]==1)) fl1=0; for (i=1;i<n+1;i++) if ((q2[i]==0)&(p2[i]==1)) fl2=0; fl=fl1||fl2; if (fl==0) cout<<"No"; else cout<<"Yes"; return 0; }please help me I found better idea. And if You want to fix bug like in my program link more stack in your memory. Can anybody help me? I have WA on the test number 9, but I don't know where I have errors in code. I think, my algorithm is true. It work on all my tests, but crash on jury test. Find errors in my code or give me that test, please. He is it: program Sum_1497; {$APPTYPE CONSOLE} var a,b,c,d,e,f,g,h,i,j,n:integer; q:array[1..1000,1..1000]of integer; ch:char; x1,x2,y1,y2:integer; function TestRect(x1,y1,x2,y2,f:integer):boolean; var i,j:integer; a:boolean; x,y:integer; begin a:=true; if f=1 then for j:=y1 to y2 do begin x:=n+1; y:=0; for i:=x1 to x2 do begin if q[j][i]=1 then if i<x then x:=i; if q[j][i]=0 then if i>y then y:=i; end; if x<y then a:=false; end; if f=2 then for j:=y1 to y2 do begin x:=0; y:=n+1; for i:=x1 to x2 do begin if q[j][i]=1 then if i>x then x:=i; if q[j][i]=0 then if i<y then y:=i; end; if x>y then a:=false; end; if f=3 then for j:=x1 to x2 do begin x:=n+1; y:=0; for i:=y1 to y2 do begin if q[i][j]=1 then if i<x then x:=i; if q[i][j]=0 then if i>y then y:=i; end; if x<y then a:=false; end; if f=4 then for j:=x1 to x2 do begin x:=0; y:=n+1; for i:=y1 to y2 do begin if q[i][j]=1 then if i>x then x:=i; if q[i][j]=0 then if i<y then y:=i; end; if x>y then a:=false; end; TestRect:=a; end; begin readln(n); for i:=1 to n do begin for j:=1 to n do begin read(ch); q[i][j]:=Ord(ch)-Ord('0'); end; readln; end; x1:=n+1; y1:=n+1; x2:=0; y2:=0; for i:=1 to n do for j:=1 to n do begin if q[i][j]=0 then begin if i>x2 then x2:=i; if i<x1 then x1:=i; if j>y2 then y2:=j; if j<y1 then y1:=j; end; end; if x1=n+1 then begin writeln('Yes'); halt; end; if (TestRect(1,y1,x2,y2,1))or(TestRect(x1,y1,n,y2,2)) or(TestRect(x1,1,x2,y2,3))or(TestRect(x1,y1,x2,n,4)) then begin writeln('Yes'); // readln(a); halt; end; writeln('No'); // readln(a); end. Comments: I find rect, in which this figure is situated. Then I test all rects, that must bu filles by "0" to free the figure. For this i find the last symbol "0" and the first symbol "1" in each line. If x (position of "0") > y(position of "1") then we cann't free the figure by this direction. There are 4 different directions: up, down, left, and right. If in any of that direction I get "true", then the answer if "Yes". Else the answer is "No". P.S. Sorry for poor English. ^_^ 4 1101 1101 1111 1111 3 111 001 111 5 11111 11000 11000 11000 11111 5 11111 00000 00000 00000 11111 Please give me answers? Edited by author 18.11.2006 13:44 Tests 1-3: Yes Test 4 is incorrect. And what about this test? 5 11000 11000 11111 11000 11000 Upss, I understand now, this is also incorrect test... :) Edited by author 09.02.2007 00:57 WHY 1-3 is true . there are is not square. explain me. please |
|