Instantly share code, notes, and snippets.

@oyakodon /A.cs
Created Aug 21, 2016

Embed
What would you like to do?
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