work

/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Solution { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner in = new Scanner (System.in); int max1,max2,t,x,y; char curr; String str,stt; max1=in.nextInt(); max2=in.nextInt(); while(in.hasNextLine()) { x= in.nextInt(); y= in.nextInt(); stt=in.next(); in.nextLine(); curr= stt.charAt(0); str= in.nextLine(); for(int i=0;i<str.length();i++) { if(str.charAt(i)=='L') { if(curr=='N') { curr='W'; } else if(curr=='S') { curr='E'; } else if(curr=='E') { curr='N'; } else { curr='S'; } } else if(str.charAt(i)=='R') { if(curr=='N') { curr='E'; } else if(curr=='S') { curr='W'; } else if(curr=='E') { curr='S'; } else { curr='N'; } } else { if(curr=='N') { y++; } else if(curr=='S') { y--; } else if(curr=='E') { x++; } else { x--; } } } System.out.println(x + " " + y+ " "+ curr); } } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.