Skip to content

Instantly share code, notes, and snippets.

@oyakodon
Created August 21, 2016 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oyakodon/3c7aec1e5d8f8e2369c7e11285308e9f to your computer and use it in GitHub Desktop.
Save oyakodon/3c7aec1e5d8f8e2369c7e11285308e9f to your computer and use it in GitHub Desktop.
AGC003 / C#
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
public class Don
{
public Don() { }
private Reader r = new Reader();
public void Solve()
{
var S = r.next();
var n = S.Count(x => x == 'N');
var s = S.Count(x => x == 'S');
var e = S.Count(x => x == 'E');
var w = S.Count(x => x == 'W');
if (((n > 0 && s > 0) || (n == 0 && s == 0)) && ((e > 0 && w > 0) || (e == 0 && w == 0)))
{
Console.WriteLine("Yes");
} else
{
Console.WriteLine("No");
}
}
public static void Main(string[] args)
{
new Don().Solve();
}
}
class Reader
{
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Reader()
{
s = new string[0];
i = 0;
}
public string next()
{
if (i < s.Length)
return s[i++];
var input = Console.ReadLine();
while (input == "")
input = Console.ReadLine();
s = input.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt()
{
return int.Parse(next());
}
public long nextLong()
{
return long.Parse(next());
}
public double nextDouble()
{
return double.Parse(next());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment