Submission #844840


Source Code Expand

import java.util.Scanner;

/**
 * Created on 2016/08/21.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();

        int N = 0;
        int W = 0;
        int E = 0;
        int S = 0;

        for(char c: str.toCharArray()){
            if(c == 'N'){
                N++;
            }
            if(c == 'W'){
                W++;
            }
            if(c == 'E'){
                E++;
            }
            if(c == 'S'){
                S++;
            }
        }

        if(N > 0){
            if(S == 0){
                System.out.println("No");
                return;
            }
        }

        if(S > 0){
            if(N == 0){
                System.out.println("No");
                return;
            }
        }

        if(E > 0){
            if(W == 0){
                System.out.println("No");
                return;
            }
        }
        if(W > 0) {
            if (E == 0) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}

Submission Info

Submission Time
Task A - Wanna go back home
User neoki
Language Java8 (OpenJDK 1.8.0)
Score 200
Code Size 1221 Byte
Status AC
Exec Time 212 ms
Memory 9936 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 4
AC × 15
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt, s4.txt
All 01.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 13.txt, 15.txt, s1.txt, s2.txt, s3.txt, s4.txt
Case Name Status Exec Time Memory
01.txt AC 209 ms 9936 KB
04.txt AC 207 ms 9296 KB
05.txt AC 212 ms 9424 KB
06.txt AC 195 ms 9424 KB
07.txt AC 195 ms 9300 KB
08.txt AC 202 ms 9424 KB
09.txt AC 203 ms 9428 KB
10.txt AC 199 ms 9296 KB
11.txt AC 203 ms 9296 KB
13.txt AC 187 ms 9296 KB
15.txt AC 203 ms 9300 KB
s1.txt AC 185 ms 9296 KB
s2.txt AC 189 ms 9300 KB
s3.txt AC 190 ms 9292 KB
s4.txt AC 191 ms 9296 KB