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

12 lines Accepted in JAVA !!!
Posted by Vahid Khodabakhshi 12 Nov 2009 14:04
import java.util.Scanner;
public class _1197 {
    public static void main( String[] args )    {
        int[][] accessibility = { { 2, 3, 4, 4, 4, 4, 3, 2 } ,{ 3, 4, 6, 6, 6, 6 ,4, 3 } ,{ 4, 6, 8, 8, 8, 8, 6, 4 } ,{ 4, 6, 8, 8, 8, 8, 6, 4 } ,{ 4, 6, 8, 8, 8, 8, 6, 4 } ,{ 4, 6, 8, 8, 8, 8, 6, 4 } ,{ 3, 4, 6, 6, 6, 6, 4, 3 } ,{ 2, 3, 4, 4, 4, 4, 3, 2 }  } ;
        Scanner in = new Scanner( System.in );
        int N = in.nextInt();
        for( int i=0 ; i<N ; i++ ) {
            String p = in.next();
            System.out.println( accessibility[p.charAt(0)-'a'][p.charAt(1)-'1'] );
        }
    }
}
Re: 12 lines Accepted in JAVA !!!
Posted by melkiy 12 Nov 2009 15:20
Stop posting your solutions, or you will be banned!
Re: 12 lines Accepted in JAVA !!!
Posted by Bogatyr 16 Sep 2012 17:50
I don't see that in the FAQ, is posting solutions disallowed?
Re: 12 lines Accepted in JAVA !!!
Posted by Bogatyr 6 Oct 2012 16:41


Edited by author 06.10.2012 19:25
Re: 12 lines Accepted in JAVA !!!whats wrong in my code
Posted by Wastabir Rajvee Alam 22 Feb 2014 01:31
import java.util.*;
public class LonesomeKnight
{
public static void main(String[] args)
{
Scanner key=new Scanner(System.in);
int a=key.nextInt();
String[] grid=new String[a];
for(int i=0;i<a;i++)
{
grid[i]=key.next();
}

for(int i=0;i<a;i++)
{
if(grid[i].equals("a1") || grid[i].equals("h1") || grid[i].equals("a8") || grid[i].equals

("h8"))
{
System.out.println(2);
}
if(grid[i].equals("a2") || grid[i].equals("b1") || grid[i].equals("g1") || grid[i].equals

("h2") || grid[i].equals("a7") || grid[i].equals("b8") || grid[i].equals("h7") || grid

[i].equals("g8") )
{
System.out.println(3);
}
if(grid[i].equals("a3") || grid[i].equals("a4") || grid[i].equals("a5") || grid[i].equals

("a6") || grid[i].equals("b2") || grid[i].equals("b7") || grid[i].equals("c1") || grid

[i].equals("c8") || grid[i].equals("d1") || grid[i].equals("d8") || grid[i].equals("e1") ||

grid[i].equals("e8") || grid[i].equals("f1") || grid[i].equals("f8") || grid[i].equals("g2") ||

grid[i].equals("g7") || grid[i].equals("h1") || grid[i].equals("h8"))
{
System.out.println(4);
}
if(grid[i].equals("b3") || grid[i].equals("b4") || grid[i].equals("b5") || grid[i].equals

("b6") || grid[i].equals("c2") || grid[i].equals("c7") || grid[i].equals("d2") || grid

[i].equals("d7") || grid[i].equals("e2") || grid[i].equals("e7") || grid[i].equals("f2") ||

grid[i].equals("f7") || grid[i].equals("g3") || grid[i].equals("g4") || grid[i].equals("g5") ||

grid[i].equals("g6"))
{
System.out.println(6);
}
if(grid[i].equals("c3") || grid[i].equals("c4") || grid[i].equals("c5") || grid[i].equals

("c6") || grid[i].equals("d3") || grid[i].equals("d4") || grid[i].equals("d5") || grid

[i].equals("d6") || grid[i].equals("e3") || grid[i].equals("e4") || grid[i].equals("e5") ||

grid[i].equals("e6") || grid[i].equals("f3") || grid[i].equals("f4") || grid[i].equals("f5") ||

grid[i].equals("f6"))
{
System.out.println(8);
}

}
}

}