পৃষ্ঠাসমূহ

সোমবার, ১৯ জুন, ২০১৭

11586 Train Tracks

import java.util.Scanner;

class Another {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int testCases = scanner.nextInt();
        scanner.nextLine();
        while (testCases-- > 0) {
            String line = scanner.nextLine();
            int ms = 0, fs = 0;
            String[] arr = line.split("\\s+");
            if (arr.length == 1) {
                System.out.println("NO LOOP");
                continue;
            }
            for (int i=0;i<arr.length;i++) {
                if (arr[i].charAt(0) == 'M') ms++;
                if (arr[i].charAt(1) == 'F') fs++;
            }

            if (ms != fs) System.out.println("NO LOOP");
            else System.out.println("LOOP");
        }

    }
}

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন