312 - Crosswords (II)

All about problems in Volume 3. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

bjacoke001
New poster
Posts: 6
Joined: Fri Jul 26, 2002 6:42 pm

312 - Crosswords (II)

Post by bjacoke001 »

Does anyone have a tricky input that would show me why I'm getting WA? I can't find any errors in my program, but apparently it's wrong. Thanks.
sjn
Learning poster
Posts: 73
Joined: Mon Apr 08, 2002 8:22 am
Contact:

Post by sjn »

Pay attention to the description of the problem
Don't use any unnecessary spaces at the end of the line.
hope this can help u :wink:
stcheung
Experienced poster
Posts: 114
Joined: Mon Nov 18, 2002 6:48 am
Contact:

over 10 WA

Post by stcheung »

First time got so frustrated with a problem. Got WA at lesat 10 times. Could anyone help...at least provide me 1 input that fails my program? Thanks in advance.

[cpp]/* 312 */

#include <iostream.h>
#include <stdlib.h>
#include <string>

string chars(char ch, int numtimes);
string numstring(int n);
string trim(string s);

int main()
{
int row, col;
while(true)
{
cin >> row >> col;
if(row == 0 && col == 0)
break;
int squares[row][col];
int crossword[row][col];
for(int i=0; i<row; i++)
{
for(int j=0; j<col; j++)
{
cin >> squares[j];
crossword[j] = 0;
}
}

int next=1;
for(int i=0; i<row; i++)
{
for(int j=0; j<col; j++)
{
if(squares[j] == 0 && (j+1 < col) && squares[j+1] == 0 &&
(j == 0 || (squares[j-1] == 1)))
{
crossword[j] = next;
next++;
}
else if(squares[j] == 0 && (i+1 < row) && squares[i+1][j] == 0 &&
(i == 0 || (squares[i-1][j] == 1)))
{
crossword[j] = next;
next++;
}
} // end of inner for
} // end of outer for


for(int i=0; i<row; i++)
{
for(int j=0; j<col; j++)
{
if(squares[j] == 1 &&
(i == 0 || j == 0 || squares[i-1][j] == -1 || squares[j-1] == -1))
squares[i][j] = -1;
}
}


for(int i=row-1; i>=0; i--)
{
for(int j=col-1; j>=0; j--)
{
if(squares[i][j] == 1 &&
(i == row-1 || j == col-1 || squares[i+1][j] == -1 || squares[i][j+1] == -1))
squares[i][j] = -1;
}
}

string first,second,third;
for(int i=0; i<row; i++)
{
first="", second="", third="";
for(int j=0; j<col; j++)
{
if(squares[i][j] != 0)
{
if((i == 0 && j == 0) ||
(i == 0 && squares[i][j-1] == -1) ||
(j == 0 && squares[i-1][j] == -1) ||
(i > 0 && j > 0 && squares[i][j-1] == -1 && squares[i-1][j] == -1 && squares[i-1][j-1] == -1))
first+=' ';
else first+='+';
if((i == 0 || squares[i-1][j] == -1) && squares[i][j] == -1)
first+=chars(' ', 4);
else first+=chars('+', 4);
if((j == 0 || squares[i][j-1] == -1) && squares[i][j] == -1)
{
second+=' ';
third+=' ';
}
else
{
second+='+';
third+='+';
}
if(squares[i][j] == -1)
{
second+=chars(' ', 4);
third+=chars(' ', 4);
}
else
{
second+=chars('+', 4);
third+=chars('+', 4);
}
}
else
{
first+=chars('+', 5);
second+='+';
second+=numstring(crossword[i][j]);
third+='+';
third+=chars(' ', 4);
}
} // end of inner for

if(squares[i][col-1] == -1)
{
if(!(i == 0 || squares[i-1][col-1] == -1))
first+='+';
}
else
{
first+='+';
second+='+';
third+='+';
}
cout << trim(first) << "\n" << trim(second) << "\n" << trim(third) << "\n";
} // end of outer for

string lastline = "";
for(int j=0; j<col; j++)
{
if(squares[row-1][j] == -1 && (j == 0 || squares[row-1][j-1] == -1))
lastline+=" ";
else lastline += "+";
if(squares[row-1][j] == -1)
lastline += chars(' ', 4);
else lastline += chars('+', 4);
}

if(squares[row-1][col-1] != -1)
lastline += "+";
cout << trim(lastline);
cout << "\n\n";
}
return 0;
}

string chars(char ch, int numtimes)
{
string result="";
while(numtimes > 0)
{
result+=ch;
numtimes--;
}
return result;
}

string numstring(int n)
{
string result="";
if(n == 0)
{
result += " ";
}
else if(n >= 100)
{
result += (char)((n/100)%10 + '0');
result += (char)((n/10)%10 + '0');
result += (char)(n%10 + '0');
}
else if(n >= 10)
{
result += "0";
result += (char)('0' + (n/10)%10);
result += (char)('0' + n%10);
}
else
{
result += "00";
result += (char)('0' + n%10);
}
return result + " ";
}

string trim(string s)
{
int i;
for(i = s.length()-1; i>=0; i--)
{
if(s[i] != ' ')
break;
}
if(i == 0)
return "";
else return s.substr(0, i+1);
}[/cpp]
GreenPenInc
Learning poster
Posts: 53
Joined: Sat May 01, 2004 9:31 pm
Contact:

Post by GreenPenInc »

I, too, think I should have AC but don't.

Here's my input:

Code: Select all

8 7
1 1 1 1 1 1 1
1 0 1 0 0 1 1
0 0 1 0 0 0 0
0 0 1 0 1 0 0
1 1 1 1 1 1 1
0 0 0 1 0 0 0
1 0 0 0 0 0 1
1 1 1 1 1 1 1
6 7
1 0 0 0 0 1 1
0 0 1 0 0 0 0
0 0 1 0 1 0 0
0 1 0 1 1 1 1
0 0 0 1 0 0 0
1 0 0 0 0 0 1
6 7
1 0 0 0 0 1 1
0 0 1 0 0 0 0
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 1 1 1 1 1 1
1 0 0 0 0 0 1
6 6
1 0 1 0 1 0
0 1 0 1 0 1
1 0 1 0 1 0
0 1 0 1 0 1
1 0 1 0 1 0
0 1 0 1 0 1
5 3
1 0 1
0 0 0
1 1 1
0 0 0
1 0 1
2 2
1 0
0 0
6 1
0
0
1
1
1
0
0 0
And, the output I get:

Code: Select all

     ++++++    +++++++++++
     +001 +    +002 +003 +
     +    +    +    +    +
+++++++++++    +++++++++++++++++++++
+004 +    +    +005 +    +006 +007 +
+    +    +    +    +    +    +    +
+++++++++++    +++++++++++++++++++++
+008 +    +    +    +    +009 +    +
+    +    +    +    +    +    +    +
+++++++++++    ++++++    +++++++++++


++++++++++++++++    ++++++++++++++++
+010 +011 +012 +    +013 +014 +    +
+    +    +    +    +    +    +    +
++++++++++++++++++++++++++++++++++++
     +015 +    +    +    +    +
     +    +    +    +    +    +
     ++++++++++++++++++++++++++

     +++++++++++++++++++++
     +001 +    +002 +003 +
     +    +    +    +    +
++++++++++++++++++++++++++++++++++++
+004 +    ++++++005 +    +006 +007 +
+    +    ++++++    +    +    +    +
++++++++++++++++++++++++++++++++++++
+008 +    ++++++    +    +009 +    +
+    +    ++++++    +    +    +    +
+++++++++++++++++++++    +++++++++++
+    ++++++010 +
+    ++++++    +
++++++++++++++++    ++++++++++++++++
+011 +012 +    +    +013 +014 +    +
+    +    +    +    +    +    +    +
++++++++++++++++++++++++++++++++++++
     +015 +    +    +    +    +
     +    +    +    +    +    +
     ++++++++++++++++++++++++++

     +++++++++++++++++++++
     +001 +    +002 +003 +
     +    +    +    +    +
++++++++++++++++++++++++++++++++++++
+004 +    +    +005 +    +    +    +
+    +    +    +    +    +    +    +
+++++++++++    +++++++++++++++++++++








     ++++++++++++++++++++++++++
     +006 +    +    +    +    +
     +    +    +    +    +    +
     ++++++++++++++++++++++++++

     ++++++    ++++++    ++++++
     +    +    +    +    +    +
     +    +    +    +    +    +
+++++++++++++++++++++++++++++++
+    ++++++    ++++++    +
+    ++++++    ++++++    +
+++++++++++++++++++++++++++++++
     +    ++++++    ++++++    +
     +    ++++++    ++++++    +
+++++++++++++++++++++++++++++++
+    ++++++    ++++++    +
+    ++++++    ++++++    +
+++++++++++++++++++++++++++++++
     +    ++++++    ++++++    +
     +    ++++++    ++++++    +
+++++++++++++++++++++++++++++++
+    +    +    +    +    +
+    +    +    +    +    +
++++++    ++++++    ++++++

     ++++++
     +001 +
     +    +
++++++++++++++++
+002 +    +    +
+    +    +    +
++++++++++++++++


++++++++++++++++
+003 +004 +    +
+    +    +    +
++++++++++++++++
     +    +
     +    +
     ++++++

     ++++++
     +001 +
     +    +
+++++++++++
+002 +    +
+    +    +
+++++++++++

++++++
+001 +
+    +
++++++
+    +
+    +
++++++








++++++
+    +
+    +
++++++

The lovely C++ which generates it (heh)

[cpp](code go bye-bye!)
[/cpp]

Any ideas? Any at all?
Last edited by GreenPenInc on Fri Aug 27, 2004 11:39 pm, edited 1 time in total.
_-(GPI)-_

"Finally I have freed myself from the clutches of the garbage fairy!"
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey »

Try this test:

Code: Select all

17 22
1 1 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1 1
1 0 1 0 1 1 1 0 0 0 0 0 1 1 1 0 0 1 0 1 1 0
0 1 0 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 1 0 1 0
1 0 0 1 1 1 1 0 1 1 1 1 1 1 0 0 1 0 0 1 0 0
0 0
Although the first and third cases are identical, your output for these cases is not!
Please don't ask me to find the bug in your code. It has something to do with the middle case: remove it from the test file, and your output is correct again...
Funny :lol:

Happy hunting.
GreenPenInc
Learning poster
Posts: 53
Joined: Sat May 01, 2004 9:31 pm
Contact:

Post by GreenPenInc »

Heh... that's weird alright. Guess that's why they call you Guru. ;)

For my reference, could you let me know what AC output looks like for that input? I'm still a little unclear on a few things. For instance, it's my understanding that for the black ones, you leave them blank if there's a direct path to the edge consisting only of other black ones, and you fill them in otherwise. Is that accurate?

Time to hunt for that bug :P Thanks again.
_-(GPI)-_

"Finally I have freed myself from the clutches of the garbage fairy!"
GreenPenInc
Learning poster
Posts: 53
Joined: Sat May 01, 2004 9:31 pm
Contact:

Post by GreenPenInc »

Okay you know what's even weirder? I just got AC (well, PE) after making the following change. At the beginning of my init() method I call a method called crazy_kill_all(void), which goes as follows:

[cpp]
/* Should do nothing; might make my program work */
void crazy_kill_all(void)
{
last_row = 0;
for (int i = 0; i < MAX; i++)
{
for (int j = 0; j < MAX; j++)
{
board[j] = 0;
visited[j] = false;
}
end_of_line = MAX;
}
}
[/cpp]

Pretty crazy eh? I think it might be some subtle bug with the visited[][] array; I might want to look into that further.

EDIT: Okay I found the bug for sure. Very idiotic of me, I must say! I didn't really need the crazy_kill_all after all, just needed to change a few < signs into <= signs. Glad to be done with this one... though, I'm still a bit muddled by the PE.
_-(GPI)-_

"Finally I have freed myself from the clutches of the garbage fairy!"
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey »

Good for you that you got AC, don't worry too much about that PE. Can't remember the verdict I got, but most of the time I just ignore them. Guess you don't need that output anymore.
I like the idea of a crazy_kill_all(), although it's a sign of weakness :wink: , I should remember that trick comes time...
My Linux clock is telling me it's 1:45 in the AM, so I'm turning in now.
Sakib
New poster
Posts: 24
Joined: Fri Jan 28, 2005 5:27 pm
Location: Bangladesh

Problem 312

Post by Sakib »

i dont understand what is wrong with my code?????
just getting WA.
but it seems all ok.
Any tricky input here or what?
can anyone help me????????
THANKS.
/* Sorry For Nothing */
johnnydog33
New poster
Posts: 10
Joined: Mon Mar 14, 2005 7:35 am

p312 TLE??

Post by johnnydog33 »

I got PE in ZJU but got TLE on UVA
I really don't know why!
Thanks for you reply

program p312;
const di:array[1..16,1..2] of integer=((0,0),(0,1),(0,2),(0,3),
(0,4),(0,5),(1,0),(1,5),
(2,0),(2,5),(3,0),(3,1),
(3,2),(3,3),(3,4),(3,5));
var a,c:array[0..25,0..25] of boolean;
b:array[0..25,0..25] of integer;
ch:array[0..500,0..500] of char;
n,m,i,j,k,x,y,ans,p,q:integer;
yes:boolean;
procedure bfs;
const d:array[1..4,1..2] of integer=((0,1),(0,-1),(1,0),(-1,0));
var f:array[1..1000,1..2] of integer;
h,t,j,v1,v2:integer;
g:array[0..25,0..25] of boolean;
begin
h:=0;t:=1;
fillchar(f,sizeof(f),0);
fillchar(g,sizeof(g),false);
while h<t do begin
inc(h);
for j:=1 to 4 do begin
v1:=f[h,1]+d[j,1];v2:=f[h,2]+d[j,2];
if (v1>=0) and (v1<=m+1) and (v2>=0) and (v2<=n+1) and not g[v1,v2] and not a[v1,v2] then begin
g[v1,v2]:=true;
inc(t);
f[t,1]:=v1;
f[t,2]:=v2;
c[v1,v2]:=true;
end;
end;
end;
end;
begin
repeat
readln(m,n);
if (m<>0) and (n<>0) then begin
fillchar(a,sizeof(a),false);
fillchar(b,sizeof(b),0);
for i:=1 to m do begin
for j:=1 to n do begin
read(x);
if x=0 then a[i,j]:=true;
end;
readln;
end;
ans:=0;
for i:=1 to m do
for j:=1 to n do
if (a[i,j] and a[i,j+1] and not a[i,j-1]) or
(a[i,j] and a[i+1,j] and not a[i-1,j]) then begin
inc(ans);
b[i,j]:=ans;
end;
fillchar(c,sizeof(c),false);
for i:=0 to m+1 do begin
a[i,0]:=false;
a[i,n+1]:=false;
end;
for i:=0 to n+1 do begin
a[0,i]:=false;
a[m+1,i]:=false;
end;
bfs;
fillchar(ch,sizeof(ch),' ');
for i:=1 to m do
for j:=1 to n do begin
x:=1+(i-1)*3;y:=1+(j-1)*5;
if a[i,j] then begin
for k:=1 to 16 do ch[x+di[k,1],y+di[k,2]]:='+';
if b[i,j]<>0 then begin
ch[x+1,y+1]:=chr(48+(b[i,j] div 100));
ch[x+1,y+2]:=chr(48+(b[i,j] div 10) mod 10);
ch[x+1,y+3]:=chr(48+(b[i,j] mod 10));
end;
end else begin
if not c[i,j] then
for p:=0 to 3 do
for q:=0 to 5 do
ch[x+p,y+q]:='+';
end;
end;
for i:=1 to 1+m*3 do begin
for j:=1 to 1+n*5 do write(ch[i,j]);
writeln;
end;
end;
writeln;
until (m=0) and (n=0);
end.
harlock
New poster
Posts: 3
Joined: Wed May 04, 2005 12:48 am

Post by harlock »

Hi, could anyone tell me the output for the next cases:

Code: Select all

7 7
0 0 1 1 1 0 0
0 1 0 0 0 1 0
1 0 0 0 0 0 1
1 0 0 1 0 0 1
1 0 0 0 0 0 1
0 1 0 0 0 1 0
0 0 1 1 1 0 0 
5 5
0 0 1 0 0
0 0 1 0 0
0 1 1 1 0
0 1 0 1 0
0 0 0 0 0
5 5
0 0 0 0 0
0 1 0 1 0
0 1 1 1 0
0 0 1 0 0
0 0 1 0 0
2 2
1 1
1 1
3 3
0 0 0
0 1 0
0 0 0
3 3
1 1 1
1 0 1
1 1 1
8 8
0 1 1 1 1 1 1 0
1 0 1 1 1 1 0 1
1 0 1 1 1 1 0 1
1 0 0 1 1 0 0 1
1 1 0 0 0 0 1 1
1 1 1 0 0 1 1 1
1 1 1 0 0 1 1 1
1 1 1 0 0 1 1 1
8 8
0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0
0 0 1 0 1 0 0 0
0 0 1 0 0 1 0 0
0 0 0 1 1 1 0 0
0 0 0 0 0 0 0 0
0 0 1 1 1 1 1 1
1 1 0 0 0 0 0 0
0 0
the output of my program is:

Code: Select all

+++++++++++              +++++++++++
+001 +    +              +002 +003 +
+    +    +              +    +    +
++++++++++++++++++++++++++++++++++++
+    ++++++004 +005 +006 ++++++    +
+    ++++++    +    +    ++++++    +
++++++++++++++++++++++++++++++++++++
     +007 +    +    +    +008 +
     +    +    +    +    +    +
     ++++++++++++++++++++++++++
     +009 +    ++++++010 +    +
     +    +    ++++++    +    +
     ++++++++++++++++++++++++++
     +011 +    +012 +    +    +
     +    +    +    +    +    +
++++++++++++++++++++++++++++++++++++
+013 ++++++014 +    +    ++++++015 +
+    ++++++    +    +    ++++++    +
++++++++++++++++++++++++++++++++++++
+016 +    +              +017 +    +
+    +    +              +    +    +
+++++++++++              +++++++++++

+++++++++++    +++++++++++
+001 +002 +    +003 +004 +
+    +    +    +    +    +
+++++++++++    +++++++++++
+005 +    +    +006 +    +
+    +    +    +    +    +
+++++++++++    +++++++++++
+    +              +    +
+    +              +    +
++++++    ++++++    ++++++
+    +    +007 +    +    +
+    +    +    +    +    +
++++++++++++++++++++++++++
+008 +    +    +    +    +
+    +    +    +    +    +
++++++++++++++++++++++++++

++++++++++++++++++++++++++
+001 +    +002 +    +003 +
+    +    +    +    +    +
++++++++++++++++++++++++++
+    +    +    +    +    +
+    +    +    +    +    +
++++++    ++++++    ++++++
+    +              +    +
+    +              +    +
+++++++++++    +++++++++++
+004 +005 +    +006 +    +
+    +    +    +    +    +
+++++++++++    +++++++++++
+007 +    +    +008 +    +
+    +    +    +    +    +
+++++++++++    +++++++++++









++++++++++++++++
+001 +    +002 +
+    +    +    +
++++++++++++++++
+    ++++++    +
+    ++++++    +
++++++++++++++++
+003 +    +    +
+    +    +    +
++++++++++++++++




     ++++++
     +    +
     +    +
     ++++++




++++++                             ++++++
+    +                             +    +
+    +                             +    +
+++++++++++                   +++++++++++
     +001 +                   +002 +
     +    +                   +    +
     ++++++                   ++++++
     +    +                   +    +
     +    +                   +    +
     +++++++++++         +++++++++++
     +003 +004 +         +005 +    +
     +    +    +         +    +    +
     +++++++++++++++++++++++++++++++
          +006 +007 +008 +    +
          +    +    +    +    +
          +++++++++++++++++++++
               +009 +    +
               +    +    +
               +++++++++++
               +010 +    +
               +    +    +
               +++++++++++
               +011 +    +
               +    +    +
               +++++++++++

+++++++++++++++++++++++++++++++++++++++++
+001 +    +    +    +    +    +    +002 +
+    +    +    +    +    +    +    +    +
+++++++++++++++++++++++++++++++++++++++++
+    +++++++++++++++++++++++++++++++    +
+    +++++++++++++++++++++++++++++++    +
+++++++++++++++++++++++++++++++++++++++++
+003 +004 ++++++005 ++++++006 +007 +    +
+    +    ++++++    ++++++    +    +    +
+++++++++++++++++++++++++++++++++++++++++
+008 +    ++++++009 +    ++++++010 +    +
+    +    ++++++    +    ++++++    +    +
+++++++++++++++++++++++++++++++++++++++++
+011 +    +012 ++++++++++++++++013 +    +
+    +    +    ++++++++++++++++    +    +
+++++++++++++++++++++++++++++++++++++++++
+014 +    +    +    +    +    +    +    +
+    +    +    +    +    +    +    +    +
+++++++++++++++++++++++++++++++++++++++++
+015 +    +
+    +    +
+++++++++++++++++++++++++++++++++++++++++
          +016 +    +    +    +    +    +
          +    +    +    +    +    +    +
          +++++++++++++++++++++++++++++++
but i'm not sure if this is correct.

My code is:

Code: Select all

cut after AC
Thanks
Last edited by harlock on Tue Jan 17, 2006 9:50 pm, edited 1 time in total.
Eric Vasquez Martinez
mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Location: Bangladesh
Contact:

Post by mamun »

Code: Select all

    for (int i=1; i<=n; i++) 
    { 
      if (M[i][1] == 0) elimina(i, 1); 
      if (M[i][n] == 0) elimina(i, m); 
    } 
In the above section

Code: Select all

      if (M[i][n] == 0) elimina(i, m); 
should be

Code: Select all

      if (M[i][m] == 0) elimina(i, m); 
likhan
New poster
Posts: 21
Joined: Tue Nov 06, 2001 2:00 am
Location: Kyliptix Solutions

Post by likhan »

Ac Output

Code: Select all

7 7
0 0 1 1 1 0 0
0 1 0 0 0 1 0
1 0 0 0 0 0 1
1 0 0 1 0 0 1
1 0 0 0 0 0 1
0 1 0 0 0 1 0
0 0 1 1 1 0 0
5 5
0 0 1 0 0
0 0 1 0 0
0 1 1 1 0
0 1 0 1 0
0 0 0 0 0
5 5
0 0 0 0 0
0 1 0 1 0
0 1 1 1 0
0 0 1 0 0
0 0 1 0 0
2 2
1 1
1 1
3 3
0 0 0
0 1 0
0 0 0
3 3
1 1 1
1 0 1
1 1 1
8 8
0 1 1 1 1 1 1 0
1 0 1 1 1 1 0 1
1 0 1 1 1 1 0 1
1 0 0 1 1 0 0 1
1 1 0 0 0 0 1 1
1 1 1 0 0 1 1 1
1 1 1 0 0 1 1 1
1 1 1 0 0 1 1 1
8 8
0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 0
0 0 1 0 1 0 0 0
0 0 1 0 0 1 0 0
0 0 0 1 1 1 0 0
0 0 0 0 0 0 0 0
0 0 1 1 1 1 1 1
1 1 0 0 0 0 0 0
0 0
My output

Code: Select all

+++++++++++              +++++++++++
+001 +    +              +002 +003 +
+    +    +              +    +    +
++++++++++++++++++++++++++++++++++++
+    ++++++004 +005 +006 ++++++    +
+    ++++++    +    +    ++++++    +
++++++++++++++++++++++++++++++++++++
     +007 +    +    +    +008 +
     +    +    +    +    +    +
     ++++++++++++++++++++++++++
     +009 +    ++++++010 +    +
     +    +    ++++++    +    +
     ++++++++++++++++++++++++++
     +011 +    +012 +    +    +
     +    +    +    +    +    +
++++++++++++++++++++++++++++++++++++
+013 ++++++014 +    +    ++++++015 +
+    ++++++    +    +    ++++++    +
++++++++++++++++++++++++++++++++++++
+016 +    +              +017 +    +
+    +    +              +    +    +
+++++++++++              +++++++++++

+++++++++++    +++++++++++
+001 +002 +    +003 +004 +
+    +    +    +    +    +
+++++++++++    +++++++++++
+005 +    +    +006 +    +
+    +    +    +    +    +
+++++++++++    +++++++++++
+    +              +    +
+    +              +    +
++++++    ++++++    ++++++
+    +    +007 +    +    +
+    +    +    +    +    +
++++++++++++++++++++++++++
+008 +    +    +    +    +
+    +    +    +    +    +
++++++++++++++++++++++++++

++++++++++++++++++++++++++
+001 +    +002 +    +003 +
+    +    +    +    +    +
++++++++++++++++++++++++++
+    +    +    +    +    +
+    +    +    +    +    +
++++++    ++++++    ++++++
+    +              +    +
+    +              +    +
+++++++++++    +++++++++++
+004 +005 +    +006 +    +
+    +    +    +    +    +
+++++++++++    +++++++++++
+007 +    +    +008 +    +
+    +    +    +    +    +
+++++++++++    +++++++++++









++++++++++++++++
+001 +    +002 +
+    +    +    +
++++++++++++++++
+    ++++++    +
+    ++++++    +
++++++++++++++++
+003 +    +    +
+    +    +    +
++++++++++++++++




     ++++++
     +    +
     +    +
     ++++++




++++++                             ++++++
+    +                             +    +
+    +                             +    +
+++++++++++                   +++++++++++
     +001 +                   +002 +
     +    +                   +    +
     ++++++                   ++++++
     +    +                   +    +
     +    +                   +    +
     +++++++++++         +++++++++++
     +003 +004 +         +005 +    +
     +    +    +         +    +    +
     +++++++++++++++++++++++++++++++
          +006 +007 +008 +    +
          +    +    +    +    +
          +++++++++++++++++++++
               +009 +    +
               +    +    +
               +++++++++++
               +010 +    +
               +    +    +
               +++++++++++
               +011 +    +
               +    +    +
               +++++++++++

+++++++++++++++++++++++++++++++++++++++++
+001 +    +    +    +    +    +    +002 +
+    +    +    +    +    +    +    +    +
+++++++++++++++++++++++++++++++++++++++++
+    +++++++++++++++++++++++++++++++    +
+    +++++++++++++++++++++++++++++++    +
+++++++++++++++++++++++++++++++++++++++++
+003 +004 ++++++005 ++++++006 +007 +    +
+    +    ++++++    ++++++    +    +    +
+++++++++++++++++++++++++++++++++++++++++
+008 +    ++++++009 +    ++++++010 +    +
+    +    ++++++    +    ++++++    +    +
+++++++++++++++++++++++++++++++++++++++++
+011 +    +012 ++++++++++++++++013 +    +
+    +    +    ++++++++++++++++    +    +
+++++++++++++++++++++++++++++++++++++++++
+014 +    +    +    +    +    +    +    +
+    +    +    +    +    +    +    +    +
+++++++++++++++++++++++++++++++++++++++++
+015 +    +
+    +    +
+++++++++++++++++++++++++++++++++++++++++
          +016 +    +    +    +    +    +
          +    +    +    +    +    +    +
          +++++++++++++++++++++++++++++++


pooya
New poster
Posts: 5
Joined: Sat Jun 16, 2007 1:18 am

Post by pooya »

What is the output for
1 0
or
0 1
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf »

pooya wrote:What is the output for
1 0
or
0 1
It's not a valid input.


For this input:

Code: Select all

1 2
1 0
1 2
0 1
0 0
my output is:

Code: Select all

     ++++++
     +    +
     +    +
     ++++++

++++++
+    +
+    +
++++++

Last edited by mf on Thu Aug 09, 2007 11:07 am, edited 1 time in total.
Post Reply

Return to “Volume 3 (300-399)”