Problem:


Score : 200 points

Problem Statement

Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip.
At the beginning of Day 1, he is at home. His plan is described in a string S of length N.
On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:

North if the i-th letter of S is N

West if the i-th letter of S is W

South if the i-th letter of S is S

East if the i-th letter of S is E

He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Constraints

1 ≦ | S | ≦ 1000

S consists of the letters N, W, S, E.

Input

The input is given from Standard Input in the following format:

S

Output

Print Yes if it is possible to set each day's travel distance so that he will be back at home at the end of Day N. Otherwise, print No.

Sample Input 1

SENW

Sample Output 1

Yes

If Snuke travels a distance of 1 on each day, he will be back at home at the end of day 4.

Sample Input 2

NSNNSNSN

Sample Output 2

Yes

Sample Input 3

NNEW

Sample Output 3

No

Sample Input 4

W

Sample Output 4

No



Sample input:
SENW


Sample output:
Yes

Submission status: Accepted

Solution code:
S = input()

compass = list(S)
vertical = []
width = []
if "N" in compass:
    vertical.append(1)
if "S" in compass:
    vertical.append(-1)
if "W" in compass:
    width.append(1)
if "E" in compass:
    width.append(-1)

if sum(vertical) == 0 and sum(width) == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
#input = sys.stdin.buffer.readline
import collections

def main():
    S = str(input())
    c = collections.Counter(S)
    c = c.keys()
    if len(c) == 4:
        print("Yes")
    elif len(c) == 2:
        if ("S" in c and "N" in c):
            print("Yes")
        elif ("W" in c and "E" in c):
            print("Yes")
        else:
            print("No")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
print("No" if (s.count("N") == 0 and s.count("S") > 0)\
		   or (s.count("S") == 0 and s.count("N") > 0)\
	       or (s.count("W") == 0 and s.count("E") > 0)\
		   or (s.count("E") == 0 and s.count("W") > 0)\
		   else "Yes")

Submission status: Accepted

Solution code:
s = input()
no = False
if (s.count("N") == 0 and s.count("S") > 0)\
  or (s.count("N") > 0 and s.count("S") == 0)\
  or (s.count("W") == 0 and s.count("E") > 0)\
  or (s.count("W") > 0 and s.count("E") == 0):
  no = True
if no:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
S = set(input())
if (("W" in S and "E" in S) or ("W" not in S and "E" not in S)) and (("N" in S and "S" in S) or ("N" not in S and "S" not in S)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
s = input()
south = s.count('S')
north = s.count('N')
east = s.count('E')
west = s.count('W')

f = lambda x, y : x == 0 and y != 0

if f(south, north) or f(north, south) or f(east, west) or f(west, east):
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:

s = list(input())

if s.count("N") == 0 and s.count("S") > 0:
    print("No")
elif s.count("S") == 0 and s.count("N") > 0:
    print("No")
elif s.count("W") == 0 and s.count("E") > 0:
    print("No")
elif s.count("E") == 0 and s.count("W") > 0:
    print("No")
else:
    print("Yes")


"""
if s.count("N") > 0 and s.count("S") > 0 and s.count("W") > 0 and s.count("E"):
    print("Yes")
elif s.count("N") == 0 and s.count("S"):
    print("Yes")
elif s.count("W") == 0 and s.count("W"):
    print("Yes")
else:
    print("No")
"""

Submission status: Accepted

Solution code:
s = list(input())

a = ('N' in s) + ('S' in s)
b = ('W' in s) + ('E' in s)

if a == 1 or b == 1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
# A - Wanna go back home
ss=input()
n=ss.count('N')
w=ss.count('W')
s=ss.count('S')
e=ss.count('E')

ns=False
if n>0 and s>0:
    ns=True
elif n==0 and s>0:
    ns=False
elif n>0 and s==0:
    ns=False
elif n==0 and s==0:
    ns=True

we=False
if w>0 and e>0:
    we=True
elif w==0 and e>0:
    we=False
elif w>0 and e==0:
    we=False
elif w==0 and e==0:
    we=True

if ns==True and we==True:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = list(input())

ans = True
if ("N" in S) and not("S" in S):
    ans = False
if ("S" in S) and not("N" in S):
    ans = False
if ("W" in S) and not("E" in S):
    ans = False
if ("E" in S) and not("W" in S):
    ans = False

if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
S=input()

if "E" in S or "W" in S:
    if "E" in S and "W" in S:
        pass
    else:
        print("No")
        exit()

if "N" in S or "S" in S:
    if "N" in S and "S" in S:
        pass
    else:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
s = input()
s = set(s)

if s==set('WE') or s==set('SN') or s==set('SNWE'):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()

dir = [0 for i in range(4)]
for i in range(len(s)):
    if s[i] == "N":
        dir[0] += 1
    elif s[i] == "W":
        dir[1] += 1
    elif s[i] == "S":
        dir[2] += 1
    elif s[i] == "E":
        dir[3] += 1

if 0 not in dir:
    print("Yes")
elif dir.count(0) == 3:
    print("No")
elif dir[0] == 0 and dir[2] == 0 or dir[1] == 0 and dir[3] == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

if (('N' in s) ^ ('S' in s)) or (('E' in s) ^ ('W' in s)):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
s = list(input())
if len(set(s)) == 4:
    print('Yes')
elif len(set(s)) == 2:
    if ('S' in s and 'N' in s) or ('E' in s and 'W' in s):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
S=set(sorted(list(input())))
if S=={'E','N','S','W'} or S=={'N','S'} or S=={'E','W'}:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()

flag = [0, 0]

if ("N" in s and "S" in s) or ("N" not in s and "S" not in s):
    flag[0] = 1
if ("W" in s and "E" in s) or ("W" not in s and "E" not in s):
    flag[1] = 1

if sum(flag) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
if (("N" in S) ^ ("S" in S)) | (("E" in S) ^ ("W" in S)):
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
s = input()

N,W,S,E = s.count("N"),s.count("W"),s.count("S"),s.count("E")

cond = 1

if N == 0 and S > 0:
	cond = 0
if S == 0 and N > 0:
	cond = 0
if W == 0 and E > 0:
	cond = 0
if E == 0 and W > 0:
	cond = 0

if cond:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
S = input().strip()
C = {"N":0,"S":0,"E":0,"W":0}
for i in range(len(S)):
    C[S[i]] += 1
if (C["N"]*C["S"]>0 or (C["N"]==0 and C["S"]==0)) and (C["E"]*C["W"]>0 or (C["E"]==0 and C["W"]==0)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = set(input())
move = [{'N', 'S', 'E', 'W'}, {'N', 'S'}, {'E', 'W'}]
if s in move:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
sl = list(input())
move = len(set(sl))

if move == 4:
    print('Yes')
elif move == 2:
    if ('N' in set(sl) and 'S' in set(sl)) or ('E' in set(sl) and 'W' in set(sl)):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
if "N" in S and "S" not in S:
  print("No")
elif "S" in S and "N" not in S:
  print("No")
elif "W" in S and "E" not in S:
  print("No")
elif "E" in S and "W" not in S:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    ans = [0, 0]
    for si in s:
        if si == "N":
            ans[0] |= 1
        elif si == "W":
            ans[1] |= 1
        elif si == "S":
            ans[0] |= 2
        else:
            ans[1] |= 2
    if ans[0] in [0, 3] and ans[1] in [0, 3]:
        print("Yes")
    else:
        print("No")
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
S=input()
flag=[]
if 'N' in S:
    if 'S' in S:
        flag.append(True)
    else:
        flag.append(False)

if 'S' in S:
    if 'N' in S:
        flag.append(True)
    else:
        flag.append(False)

if 'W' in S:
    if 'E' in S:
        flag.append(True)
    else:
        flag.append(False)

if 'E' in S:
    if 'W' in S:
        flag.append(True)
    else:
        flag.append(False)

if False in flag:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
S=input()

Nflag=False
Wflag=False
Sflag=False
Eflag=False

if "N" in S:
   Nflag=True
if "W" in S:
   Wflag=True
if "S" in S:
   Sflag=True
if "E" in S:
   Eflag=True

if Nflag and Wflag and Sflag and Eflag:
   print("Yes")
elif Nflag and Sflag and Wflag==False and Eflag==False:
   print("Yes")
elif Nflag==False and Sflag==False and Wflag and Eflag:
   print("Yes")
else:
   print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
S = input()
l = {"E":0, "W":0, "S":0, "N":0}
for i in range(len(S)):
    l[S[i]] += 1
f1, f2 = False, False
if (l["W"] != 0 and l["E"] != 0) or l["W"] == l["E"] == 0:
    f1 = True
if (l["N"] != 0 and l["S"] != 0) or l["N"] == l["S"] == 0:
    f2 = True
print("Yes" if f1 and f2 else "No")

Submission status: Accepted

Solution code:
s = set(list(str(input())))
if s == {'N', 'S', 'E', 'W'} or s == {'N', 'S'} or s == {'E', 'W'}:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
s=list(input())
if s.count('N')>0 and s.count('S')>0 and s.count('E')>0 and s.count('W')>0:
    print('Yes')
elif s.count('N')>0 and s.count('S')>0 and s.count('E')==0 and s.count('W')==0:
    print('Yes')
elif s.count('N')==0 and s.count('S')==0 and s.count('E')>0 and s.count('W')>0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = set(read().rstrip().decode('utf-8'))

answer = 'Yes'
for x,y in ['EW','NS','WE','SN']:
    if x in S and y not in S:
        answer = 'No'

print(answer)

Submission status: Accepted

Solution code:
S = input()
if not (('W' in S) ^ ('E' in S)) and not (('N' in S) ^ ('S' in S)):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S=input()
n,w,s,e=0,0,0,0
for i in range(len(S)):
    if S[i]=="N":
        n=1
    elif S[i]=="W":
        w=1
    elif S[i]=="S":
        s=1
    else:
        e=1
if n*w*s*e==1 or n*s==1 and w==0 and e==0 or w*e==1 and n==0 and s==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
n, e, w, s = 0, 0, 0, 0
for i in range(len(S)):
  if S[i] == 'N':
    n = 1
  elif S[i] == 'E':
    e = 1
  elif S[i] == 'W':
    w = 1
  elif S[i] == 'S':
    s = 1
if n == s and e == w:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
def main(S):
    d = {x: 0 for x in "NWES"}
    for s in S:
        d[s] += 1
    if d["N"] * d["S"] == 0 and d["N"] + d["S"] != 0:
        return "No"
    if d["E"] * d["W"] == 0 and d["E"] + d["W"] != 0:
        return "No"
    return "Yes"


if __name__ == "__main__":
    S = input()
    ans = main(S)
    print(ans)

Submission status: Accepted

Solution code:
s=input()
N = s.count("N")
E = s.count("E")
W = s.count("W")
S = s.count("S")
if ((N==S==0 and E>0 and W>0)
    or (E==W==0 and N>0 and S>0)
    or (N>0 and S>0 and E>0 and W>0)):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S = input()

directions = [False for _ in range(4)]
for s in S:
    if s == 'S':
        directions[0] = True
    if s == 'N':
        directions[1] = True
    if s == 'W':
        directions[2] = True
    if s == 'E':
        directions[3] = True


if directions[0] ^ directions[1] or directions[2] ^ directions[3]:
    print('No')

else:
    print('Yes')

Submission status: Accepted

Solution code:
S = input()

if (('E' in S) ^ ('W' in S)) or (('N' in S) ^ ('S' in S)) :
  print('No')
else :
  print('Yes')

Submission status: Accepted

Solution code:
s=input()
l=[x in s for x in list("NEWS")]
if (l[-1]==l[0]) and (l[1]==l[2]):
  print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
#coding:utf-8
from collections import defaultdict
S = input()
dd = defaultdict(int)
for s in S:
    dd[s]+=1
if ((dd['S']>0)^(dd['N']>0)):
    print ("No")
elif((dd['E']>0)^(dd['W']>0)):
    print ("No")
else:
    print ("Yes")

Submission status: Accepted

Solution code:
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

s = input()
ansns = 0
ansew = 0

ansns = s.count("N") * s.count("S")
if s.count("N")==0 and s.count("S")==0:
	ansns = 1

ansew = s.count("E") * s.count("W")
if s.count("E")==0 and s.count("W")==0:
	ansew = 1

ans = ansns * ansew

print("Yes" if ans!=0 else "No")

Submission status: Accepted

Solution code:
s=input()

N=0
S=0
E=0
W=0

for i in s:
	if i=="N":
		N=1
	if i=="S":
		S=1
	if i=="E":
		E=1
	if i=="W":
		W=1
		
if N+S==1 or E+W==1:
	ans="No"
else:
	ans="Yes"
print(ans)

Submission status: Accepted

Solution code:
S =input()
if (('N' in S) == ('S' in S)) and (('W' in S) == ('E' in S)):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
d = {'N': 0, 'S': 0, 'W': 0, 'E': 0}
for s in S:
    d[s] = 1

ans = "Yes"
if (d['N'] ^ d['S']) or (d['W'] ^ d['E']):
    ans = "No"

print(ans)

Submission status: Accepted

Solution code:
a = list(input())

n = a.count('N')
s = a.count('S')
w = a.count('W')
e = a.count('E')

if n * s == 0 and n + s > 0:
    print('No')
elif e * w == 0 and e + w > 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
S = input()
if len(S)==1:
  print('No')
  exit()

cntN = S.count('N')
cntW = S.count('W')
cntS = S.count('S')
cntE = S.count('E')

f1, f2 = False, False
if (cntN == 0 and cntS == 0) or (cntN > 0 and cntS > 0): f1 = True
if (cntW == 0 and cntE == 0) or (cntW > 0 and cntE > 0): f2 = True
print('Yes' if f1 is True and f2 is True else 'No' )

Submission status: Accepted

Solution code:
from collections import Counter

S = list(set(list(input())))

x = [0, 0]
for s in S:
    if s == "E":
        x[0] += 1
    elif s == "W":
        x[0] -= 1
    elif s == "N":
        x[1] += 1
    elif s == "S":
        x[1] -= 1

print('Yes' if x == [0, 0] else 'No')

Submission status: Accepted

Solution code:
s = input()

if (('N' in s and 'S' not in s) or
    ('S' in s and 'N' not in s) or
    ('E' in s and 'W' not in s) or
    ('W' in s and 'E' not in s)):

    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
def examA():
    S = SI()
    d = defaultdict(bool)
    ans = "Yes"
    for s in S:
        d[s] = True
    if (d["S"] and (not d["N"])) or (d["N"] and (not d["S"])):
        ans = "No"
    if (d["E"] and (not d["W"])) or (d["W"] and (not d["E"])):
        ans = "No"
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examA()

Submission status: Accepted

Solution code:
s=input()
x=[0,0,0,0]
for i in s:
    if i=="N":
        x[0]=1
    elif i=="S":
        x[1]=1
    elif i=="W":
        x[2]=1
    else:
        x[3]=1
#print(x)
if x==[1,1,1,1] or x==[0,0,1,1] or x==[1,1,0,0]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
set1 = {"W","N","S","E"}
set2 = {"W","E"}
set3 = {"N","S"}

if set(s) == set1:
    print("Yes")
elif set(s) == set2:
    print("Yes")
elif set(s) == set3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = set(input())
if (("W" in S and "E" in S) or ("W" not in S and "E" not in S)) and (("S" in S and "N" in S) or ("S" not in S and "N" not in S)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from sys import stdin

s = stdin.readline().rstrip()
s = [str(i) for i in s]

s = list(set(s))
s.sort()

if s == ["N","S"] or s == ["E","W"] or s == ["E","N","S","W"]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    print(YES if (('W' in S) == ('E' in S))  and (('N' in S) == ('S' in S)) else NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter

s=input()
c=Counter(s)
if ((c['N']==0 and c['S']==0) or (c['N']!=0 and c['S']!=0)) and ((c['W']==0 and c['E']==0) or (c['W']!=0 and c['E']!=0)):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
N = S.count("N")
W = S.count("W")
E = S.count("E")
S = S.count("S")

if N+S and N*S == 0 or E+W and E*W == 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
# coding: utf-8
def main():
    s = set(input())
    l = len(s)
    if l % 2 != 0:
        print('No')
    else:
        if 'N' in s and 'S' in s:
            print('Yes')
        elif 'W' in s and 'E' in s:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = set(list(input()))
NS = ("N" in S) == ("S" in S)
WE = ("W" in S) == ("E" in S)
if NS and WE:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = input()
if len(set(s))%2 == 0 and ((s.count("N") and s.count("S")) != 0 or (s.count("W") and s.count("E")) != 0):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S = input()
if ('N' in S and 'S' not in S) or ('S' in S and 'N' not in S) or ('E' in S and 'W' not in S) or ('W' in S and 'E' not in S):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
s = set(input())

t = 0
for _s in s:
    if _s == "N":
        t += 1
    if _s == "S":
        t -= 1
    if _s == "E":
        t += 2
    if _s == "W":
        t -= 2

print("Yes" if t == 0 else "No")

Submission status: Accepted

Solution code:
s = input()
if (-1) ** (int("N" in s) + int("S" in s))==1 and (-1) ** (int("E" in s) + int("W" in s))==1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S = list(set(list(input())))
c = 0
for i in S:
    if i == "N":
        c += 1
    elif i == "W":
        c += 2
    elif i == "S":
        c -= 1
    else:
        c -= 2
if c == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
dic={"W":1,"E":-1,"N":10,"S":-10}
ans=0
for c in set(list(input())):
  ans+=dic[c]
print(("No","Yes")[ans==0])

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
c = Counter(s)
a,b,c,d = [c['N'], c['S'], c['W'], c['E']]
if (a and b) or (not a and not b):
    if (c and d) or (not c and not d):
        print('Yes')
        quit()
print('No')

Submission status: Accepted

Solution code:
# AGC 003: A – Wanna go back home
s = input()
print('No' if ('N' in s and 'S' not in s) or ('N' not in s and 'S' in s) or ('E' in s and 'W' not in s) or ('E' not in s and 'W' in s) else 'Yes')

Submission status: Accepted

Solution code:

S = input()

dic = {}

for i in S:

    dic[i] = 1

if len(dic) == 4:
    print ("Yes")

elif len(dic) == 2 and (("N" in dic and "S" in dic) or ("W" in dic and "E" in dic)) :
    print ("Yes")

else:
    print ("No")

Submission status: Accepted

Solution code:
def inpl():
    return list(map(int, input().split()))


def f(a, b):
    if a == 0 and b == 0:
        return True
    elif a * b == 0:
        return False
    else:
        return True


S = input()
# print(S)
cN = S.count('N')
cW = S.count('W')
cS = S.count('S')
cE = S.count('E')

if f(cN, cS) is True and f(cW, cE) is True:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = list(input())
N = s.count("N")
W = s.count("W")
S = s.count("S")
E = s.count("E")
ans = "Yes"

if N>=1 and S==0:
    ans = "No"
elif N==0 and S>=1:
    ans = "No"

if W>=1 and E==0:
    ans = "No"
elif W==0 and E>=1:
    ans = "No"

print(ans)

Submission status: Accepted

Solution code:
s = [c for c in input()]
a = [0, 0, 0, 0]
for c in s:
    if c == 'N':
        a[0] += 1
    elif c == 'S':
        a[1] += 1
    elif c == 'E':
        a[2] += 1
    elif c == 'W':
        a[3] += 1
if (a[0] != 0 and a[1] == 0 or a[0] == 0 and a[1] != 0) \
    or (a[2] != 0 and a[3] == 0 or a[2] == 0 and a[3] != 0):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
s=list(input())
if s.count('N')>0 and s.count('S')>0 and s.count('E')>0 and s.count('W')>0:
    print('Yes')
elif s.count('N')>0 and s.count('S')>0 and s.count('E')==0 and s.count('W')==0:
    print('Yes')
elif s.count('N')==0 and s.count('S')==0 and s.count('E')>0 and s.count('W')>0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
pos = {'N':0, 'W':0, 'S':0, 'E':0}

for s in input(): pos[s] += 1
    
ans = 'Yes'

if not (pos['N'] and pos['S'] or not pos['N'] and not pos['S']): ans = 'No'
if not (pos['W'] and pos['E'] or not pos['W'] and not pos['E']): ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
s = list(input())

north = s.count("N")
west = s.count("W")
south = s.count("S")
east = s.count("E")

if north == 0:
    if south > 0:
        print("No")
        exit()
if south == 0:
    if north > 0:
        print("No")
        exit()
if west == 0:
    if east > 0:
        print("No")
        exit()
if east == 0:
    if west > 0:
        print("No")
        exit()
        
print("Yes")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import collections

S = input()
c = collections.Counter(S)
ans = "No"

if (c["N"] > 0 and c["S"] > 0) or (c["N"] == 0 and c["S"] == 0):
    if (c["W"] > 0 and c["E"] > 0) or (c["W"] == 0 and c["E"] == 0):
        ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

S = input()
d = defaultdict(int)
for i in S:
    d[i] += 1

if len(d) == 1 or len(d) == 3:
    print('No')
else:
    if len(d) == 4:
        print('Yes')
    elif 'N' in d:
        if 'S' in d:
            print('Yes')
        else:
            print('No')
    elif 'W' in d:
        if 'E' in d:
            print('Yes')
        else:
            print('No')
    else:
        print('No')

Submission status: Accepted

Solution code:
S = input()
cnt_n = 0
cnt_w = 0
cnt_s = 0
cnt_e = 0

for i in S:
    if i == "N":
        cnt_n += 1
    elif i == "W":
        cnt_w += 1
    elif i == "S":
        cnt_s += 1
    else:
        cnt_e += 1

if cnt_n * cnt_w * cnt_s * cnt_e > 0:
    print("Yes")
elif (cnt_n == 0 and cnt_s == 0) and cnt_e * cnt_w > 0:
    print("Yes")
elif (cnt_n * cnt_s > 0) and (cnt_e == 0 and cnt_w == 0):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S=input()


if "W" in S:
    if not "E" in S:
        print("No")
        exit()

if "E" in S:
    if not "W" in S:
        print("No")
        exit()

if "N" in S:
    if not "S" in S:
        print("No")
        exit()

if "S" in S:
    if not "N" in S:
        print("No")
        exit()
        
print("Yes")

Submission status: Accepted

Solution code:
s = input()
if ('N' in s) == ('S' in s) and ('W' in s) == ('E' in s):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

NS = ('N' in S and 'S' in S) or ('N' not in S and 'S' not in S)
EW = ('E' in S and 'W' in S) or ('E' not in S and 'W' not in S)

if NS and EW:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def NS(s):
    return 'N' in s and 'S' in s

def EW(s):
    return 'W' in s and 'E' in s

s = list(input())
if len(set(s)) == 2:
    if NS(s) or EW(s):
        print("Yes")
    else:
        print("No")
elif len(set(s)) == 4:
    if NS(s) and EW(s):
        print("Yes")
    else:
        print("No")    
else:
    print("No")

Submission status: Accepted

Solution code:
str = input()

n,s,e,w = -1,-1,-1,-1

n = str.find("N")
s = str.find("S")
e = str.find("E")
w = str.find("W")

ch = 1

if(n>=0 and s==-1):
    ch  = 0
elif(n==-1 and s>=0):
    ch  = 0
elif(w>=0 and e==-1):
    ch = 0
elif(e>=0 and w==-1):
    ch = 0

if(ch):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter

S = input()

c = Counter(S)
print('No' if bool(c['N']) ^ bool(c['S']) |
      bool(c['W']) ^ bool(c['E']) else 'Yes')

Submission status: Accepted

Solution code:
S = input()
n = False
s = False
e = False
w = False

if 'N' in S:
    n = True
if 'S' in S:
    s = True
if 'E' in S:
    e = True
if 'W' in S:
    w = True

if n == s and e == w:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = set(list(input()))

if len(S) == 4:
    print('Yes')
elif len(S) == 1 or len(S) == 3:
    print('No')
else:
    if {'N', 'S'} == S or {'W', 'E'} == S:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
s = input()
A = ["N", "S", "E", "W"]
B = [0] * 4
for i in range(4):
    B[i] = s.count(A[i]) > 0

print("No" if (B[0]^B[1]) or (B[2]^B[3]) else "Yes")

Submission status: Accepted

Solution code:
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    s = collections.Counter(str(input().rstrip('\n')))
    if len(s) == 4:
        print("Yes")
    elif len(s) == 2:
        if "N" in s and "S" in s:
            print("Yes")
        elif "E" in s and "W" in s:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- Coding: utf-8 -*-

import sys


def main():
    S = input()
    ary = ['N' in S, 'W' in S, 'S' in S, 'E' in S]

    if ary[0] == ary[2] and ary[1] == ary[3]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
src = input()
a = False
b = False
c = False
d = False
for s in src:
    if s == 'N':
        a = True
    elif s == 'W':
        b = True
    elif s == 'S':
        c = True
    elif s == 'E':
        d = True
if a != c or b != d:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
S=input()
[fN,fS,fE,fW]=[False]*4
for c in S:
    if fN and fS and fE and fW:
        break
    if c=='N':
        fN=True
    if c=='S':
        fS=True
    if c=='E':
        fE=True
    if c=='W':
        fW=True

if (fN and not fS) or (not fN and fS) or (fE and not fW) or (not fE and fW):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
T = input()

N = T.count('N')
S = T.count('S')
W = T.count('W')
E = T.count('E')

if N > 0 and S == 0 or S > 0 and N == 0:
    print('No')
elif W > 0 and E == 0 or E > 0 and W == 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys,os,random
S=input()
c={}
c['S']=c['N']=c['E']=c['W']=0
for i in S:c[i]=1
if(c['S']^c['N'])or(c['E']^c['W']):print("No")
else:print("Yes")

Submission status: Accepted

Solution code:
s=list(input())
if ("N"  not in s and "S" in s) or ("N" in s and "S" not in s) or ("E"  not in s and "W" in s) or ("E" in s and "W" not in s):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
s = set(input())
if s in [{"N", "W", "S", "E"}, {"N", "S"}, {"W", "E"}]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S=list(input())

S.sort()
e,w,n,s=S.count('E'),S.count('W'),S.count('N'),S.count('S')
flag=True
if max(e,w)>0 and min(e,w)==0:
  flag=False
if max(n,s)>0 and min(n,s)==0:
  flag=False
  
if flag:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n = input()
sets = set(n)
flg = False
for i in [{'N','S','W','E'},{'N','S'},{'W','E'}]:
    if sets == i:
        flg = True
        break
     
print('Yes' if flg else 'No')

Submission status: Accepted

Solution code:
s = input()

if "N" in s and "S" not in s:
    print("No")
elif "S" in s and "N" not in s:
    print("No")
elif "E" in s and "W" not in s:
    print("No")
elif "W" in s and "E" not in s:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
S = input()
nwse = [0, 0, 0, 0]

for x in S:
    if x == "N":
        nwse[0] += 1
    elif x == "W":
        nwse[1] += 1
    elif x == "S":
        nwse[2] += 1
    elif x == "E":
        nwse[3] += 1

if nwse[0] > 0 and nwse[2] > 0 or nwse[0] == 0 and nwse[2] == 0:
    if nwse[1] > 0 and nwse[3] > 0 or nwse[1] == 0 and nwse[3] == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
s=set(list(input()))
print("Yes" if len(s)%2==0 and (("N" in s and "S" in s) or ("E" in s and "W" in s))  else "No")

Submission status: Accepted

Solution code:
s = input()
ans =0
if 'N' in s and 'S' not in s:
  ans =1
elif 'S' in s and 'N' not in s:
  ans =1
elif 'W' in s and 'E' not in s:
  ans =1
elif 'E' in s and 'W' not in s:
  ans =1
print('No' if ans ==1 else 'Yes')