Submission #533450


Source Code Expand

import java.util.Scanner;

class Main {

    public final static String[] strs = { "tokyo", "kyoto" };

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

        int T = sc.nextInt();
        String[] S = new String[T];

        for (int i = 0; i < T; i++) {
            S[i] = sc.next();
        }

        sc.close();

        for (int i = 0; i < T; i++) {
            cutTapu(S[i]);
        }

    }

    public static void cutTapu(String str) {
        int count = 0;
        int fromIndex = 0;
        while (true) {

            int indexa = Integer.MAX_VALUE;
            for (String s : strs) {
                int index = str.indexOf(s, fromIndex);

                if (index == -1) {
                    continue;
                }

                indexa = Math.min(indexa, index);

            }

            if (indexa == Integer.MAX_VALUE) {
                break;
            }
            count++;
            fromIndex = indexa + 5;

        }

         System.out.println(count);
    }
}

Submission Info

Submission Time
Task A - 東京都
User briongloid
Language Java (OpenJDK 1.7.0)
Score 100
Code Size 1099 Byte
Status AC
Exec Time 531 ms
Memory 25868 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 3
Set Name Test Cases
All 10_random_to_kyo.txt, 20_noised_tokyoto.txt, 99_teuchi.txt
Case Name Status Exec Time Memory
10_random_to_kyo.txt AC 529 ms 25820 KB
20_noised_tokyoto.txt AC 531 ms 25868 KB
99_teuchi.txt AC 488 ms 23960 KB