Submission #11563094


Source Code Expand

import java.util.*;
import static java.lang.System.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		boolean[] flag = new boolean[4];
		char[] str = sc.next().toCharArray();
		for(char c: str) {
			if (c == 'N')
				flag[0] = true;
			if(c == 'S')
				flag[1] = true;
			if (c == 'W')
				flag[2] = true;
			if (c == 'E')
				flag[3] = true;
		}
		
		if (
			flag[0] && !flag[1] || flag[1] && !flag[0]
			|| flag[2] && !flag[3] || !flag[2] && flag[3]			
				)
			out.println("No");
		else
			out.println("Yes");
		
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}

Submission Info

Submission Time
Task A - Wanna go back home
User ampm
Language Java8 (OpenJDK 1.8.0)
Score 200
Code Size 2848 Byte
Status AC
Exec Time 72 ms
Memory 21844 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 71 ms 18900 KB
04.txt AC 72 ms 20692 KB
05.txt AC 69 ms 17620 KB
06.txt AC 71 ms 20692 KB
07.txt AC 70 ms 21844 KB
08.txt AC 72 ms 18388 KB
09.txt AC 70 ms 18004 KB
10.txt AC 71 ms 19668 KB
11.txt AC 70 ms 18900 KB
13.txt AC 71 ms 18260 KB
15.txt AC 70 ms 21460 KB
s1.txt AC 72 ms 20820 KB
s2.txt AC 70 ms 19156 KB
s3.txt AC 70 ms 18644 KB
s4.txt AC 71 ms 18772 KB