AtCoder Grand Contest (AGC) 003
実際に提出したコードです。
A問題のみ、A問題はACです。
-
-
Save oyakodon/3c7aec1e5d8f8e2369c7e11285308e9f to your computer and use it in GitHub Desktop.
AGC003 / C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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