fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Codechef
  7. {
  8. static int n,m,flag;
  9. static int arr[][];
  10. public static boolean chk(int x,int y)
  11. {
  12. if(x>=1 && x<=n && y>=1 && y<=m)
  13. return true;
  14.  
  15. return false;
  16. }
  17. public static void print (int arr[][],int cx,int cy)
  18. {
  19. int i,j;
  20. for(i=1;i<=n;i++)
  21. {
  22. for(j=1;j<=m;j++)
  23. System.out.print(arr[i][j]);
  24.  
  25. System.out.println();
  26. }
  27. System.out.print(cx+" "+cy);
  28. System.out.println();
  29. }
  30.  
  31. public static void cal(int cx,int cy,int dx,int dy)
  32. {
  33. if(flag==0){
  34.  
  35. arr[cx][cy]=1;
  36. if(cx==dx && cy==dy)
  37. {
  38. flag=1;
  39. if(chk(cx,cy+1)==true && arr[cx][cy+1]==0)
  40. {System.out.println("Right");return;}
  41.  
  42. if(chk(cx,cy-1)==true && arr[cx][cy-1]==0)
  43. {System.out.println("Left");return;}
  44.  
  45. if(chk(cx-1,cy)==true && arr[cx-1][cy]==0)
  46. {System.out.println("Front");return;}
  47.  
  48. if(chk(cx+1,cy)==true && arr[cx+1][cy]==0)
  49. {System.out.println("Back");return;}
  50.  
  51. System.out.println("Over");return;
  52.  
  53. }
  54. else
  55. {
  56. if(chk(cx,cy+1)==true && arr[cx][cy+1]==0)
  57. {
  58. cal(cx,cy+1,dx,dy);
  59. }
  60. if(chk(cx,cy-1)==true && arr[cx][cy-1]==0)
  61. {
  62. cal(cx,cy-1,dx,dy);
  63. }
  64. if(chk(cx-1,cy)==true && arr[cx-1][cy]==0)
  65. {
  66. cal(cx-1,cy,dx,dy);
  67. }
  68. if(chk(cx+1,cy)==true && arr[cx+1][cy]==0)
  69. {
  70. cal(cx+1,cy,dx,dy);
  71. }
  72. }
  73. }
  74.  
  75.  
  76. }
  77. public static void main () throws java.lang.Exception
  78. {
  79. // your code goes here
  80. System.out.println("ee");
  81. int t = Integer.parseInt(br.readLine());
  82. for(;t!=0;t--)
  83. {
  84. int sx,sy,dx,dy;
  85. StringTokenizer st = new StringTokenizer(br.readLine());
  86. n=Integer.parseInt(st.nextToken());
  87. m=Integer.parseInt(st.nextToken());
  88.  
  89. st = new StringTokenizer(br.readLine());
  90. sx=Integer.parseInt(st.nextToken());
  91. sy=Integer.parseInt(st.nextToken());
  92.  
  93. st = new StringTokenizer(br.readLine());
  94. dx=Integer.parseInt(st.nextToken());
  95. dy=Integer.parseInt(st.nextToken());
  96.  
  97. arr= new int[1001][1001];
  98. flag=0;
  99. cal(sx,sy,dx,dy);
  100. }
  101. }
  102. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
spoj: The program compiled successfully, but main class was not found.
      Main class should contain method: public static void main (String[] args).
stdout
Standard output is empty