ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1197. Lonesome Knight

Help
Posted by sialLeo 30 Mar 2013 01:59
What's wrong with this code?
var i,n,num:integer; ch:char;st:string;
begin
readln(n);
for i:=1 to n do begin
  readln(st);
  num:=ord(st[2])-ord('0');
  ch:=st[1];

  if ((ch='a')or(ch='h')) then begin
     if ((num=1)or(num=8)) then writeln(2)
     else if ((num=2)or(num=7)) then writeln(3)
     else if num in[3..6] then writeln(4);
     end
  else
  if ((ch='b')or(ch='g')) then begin
     if ((num=1)or(num=8)) then writeln(3)
     else if  ((num=2)or(num=7)) then writeln(4)
     else if num in[3..6] then write(6);
  end
  else
  if ((ch='c')or(ch='d')or(ch='e')or(ch='f')) then begin
    if ((num=1)or(num=8)) then writeln(4)
    else if  ((num=2)or(num=7)) then writeln(6)
    else if num in[3..6] then writeln(8);
    end;
  end;
end.

I've tested all 64 cases and it works, but i still get WA2.

Edited by author 30.03.2013 02:00
Re: Help
Posted by Vincas Stonys 30 Mar 2013 04:33
 else if num in[3..6] then write(6);

should be writeln(6).

everything else is fine ;)
Re: Help
Posted by sialLeo 1 Apr 2013 19:43
Thank you, bro! :)