Submission #1289435


Source Code Expand

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String S = br.readLine();
        String[] str_array = S.split("");
        int y_count = 0;
        int a_count = 0;
        int h_count = 0;
        int o_count = 0;
        boolean shouldPrintYES = true;
        for (String e: str_array){
            if (e.equals("o")){
                o_count += 1;
                if (o_count > 2) { 
                    System.out.println("NO");
                    shouldPrintYES = false;
                    break;
                }
            } else if (e.equals("y")) {
                y_count += 1;
                if (y_count > 1) { 
                    System.out.println("NO");
                    shouldPrintYES = false;
                    break;
                }
            } else if (e.equals("h")) {
                h_count += 1;
                if (h_count > 1) { 
                    System.out.println("NO");
                    shouldPrintYES = false;
                    break;
                }
            } else if (e.equals("a")) {
                a_count += 1;
                if (a_count > 1) { 
                    System.out.println("NO");
                    shouldPrintYES = false;
                    break;
                }
            } else {
                System.out.println("NO");
                shouldPrintYES = false;
                break;
            }
        }
        if (shouldPrintYES == true){
            System.out.println("YES");
        }
    }
}

Submission Info

Submission Time
Task A - Yahoo
User toco1001
Language Java8 (OpenJDK 1.8.0)
Score 100
Code Size 1762 Byte
Status AC
Exec Time 71 ms
Memory 23124 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 4
AC × 17
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt, sample4.txt
All sample1.txt, sample2.txt, sample3.txt, sample4.txt, in1.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt
Case Name Status Exec Time Memory
in1.txt AC 68 ms 19412 KB
in2.txt AC 69 ms 22996 KB
in3.txt AC 68 ms 17236 KB
in4.txt AC 71 ms 19156 KB
in5.txt AC 70 ms 18644 KB
in6.txt AC 71 ms 21072 KB
in7.txt AC 69 ms 21204 KB
in8.txt AC 68 ms 19156 KB
in9.txt AC 69 ms 21332 KB
sample1.txt AC 69 ms 19156 KB
sample2.txt AC 70 ms 19028 KB
sample3.txt AC 68 ms 18516 KB
sample4.txt AC 69 ms 23124 KB