Submission #844829


Source Code Expand

import java.util.Scanner;

public class Main {
  static String s;

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

    s = sc.next();

    int n = s.length();
    int[] counts = new int[26];
    for(int i = 0; i < n; i++){
      ++counts[s.charAt(i) - 'A'];
    }

    boolean ok = true;
    if(counts['N' - 'A'] >= 1 && counts['S'- 'A'] < 1){
      ok = false;
    }
    if(counts['S'- 'A'] >= 1 && counts['N'- 'A'] < 1){
      ok = false;
    }
    if(counts['W'- 'A'] >= 1 && counts['E'- 'A'] < 1){
      ok = false;
    }
    if(counts['E'- 'A'] >= 1 && counts['W'- 'A'] < 1){
      ok = false;
    }

    if(ok){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Submission Info

Submission Time
Task A - Wanna go back home
User rom
Language Java8 (OpenJDK 1.8.0)
Score 200
Code Size 783 Byte
Status AC
Exec Time 222 ms
Memory 9940 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 219 ms 9940 KB
04.txt AC 202 ms 9292 KB
05.txt AC 210 ms 9296 KB
06.txt AC 202 ms 9424 KB
07.txt AC 194 ms 9296 KB
08.txt AC 202 ms 9424 KB
09.txt AC 198 ms 9296 KB
10.txt AC 222 ms 9428 KB
11.txt AC 202 ms 9428 KB
13.txt AC 221 ms 9300 KB
15.txt AC 205 ms 9296 KB
s1.txt AC 194 ms 9296 KB
s2.txt AC 198 ms 9296 KB
s3.txt AC 202 ms 9300 KB
s4.txt AC 190 ms 9292 KB