import java.util.ArrayList; import java.util.Scanner; class Another { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int testCases = scanner.nextInt(); while (testCases-- > 0) { int commands = scanner.nextInt(); int value = 0; ArrayList<String> cmnds = new ArrayList<>(); scanner.nextLine(); while (commands-- > 0) { String command = scanner.nextLine(); cmnds.add(command); while (true) { if (command.equals("LEFT")) { value--; break; } else if (command.equals("RIGHT")) { value++; break; } else { String arr[] = command.split(" "); command = cmnds.get(Integer.parseInt(arr[2])-1); } } } System.out.println(value); } } }
বুধবার, ১৪ জুন, ২০১৭
12503 Robot Instructions
এতে সদস্যতা:
মন্তব্যগুলি পোস্ট করুন (Atom)
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন