Submission #844441


Source Code Expand

Copy
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            int[] cnt = new int[256];
            for (int i = 0; i < s.length(); ++i) ++cnt[s.charAt(i)];
            if (cnt['E'] == 0 ^ cnt['W'] == 0) {
                out.println("No");
                return;
            }
            if (cnt['N'] == 0 ^ cnt['S'] == 0) {
                out.println("No");
                return;
            }
            out.println("Yes");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}

Submission Info

Submission Time
Task A - Wanna go back home
User Petr
Language Java8 (OpenJDK 1.8.0)
Score 200
Code Size 1975 Byte
Status AC
Exec Time 168 ms
Memory 8276 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 155 ms 8276 KB
04.txt AC 168 ms 8144 KB
05.txt AC 155 ms 8272 KB
06.txt AC 151 ms 8276 KB
07.txt AC 155 ms 8148 KB
08.txt AC 155 ms 8144 KB
09.txt AC 167 ms 8148 KB
10.txt AC 155 ms 8144 KB
11.txt AC 151 ms 8148 KB
13.txt AC 155 ms 8148 KB
15.txt AC 153 ms 8144 KB
s1.txt AC 153 ms 8148 KB
s2.txt AC 147 ms 8144 KB
s3.txt AC 151 ms 8148 KB
s4.txt AC 151 ms 8148 KB