Submission #3599726
Source Code Expand
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Practice { class Program { static void Main(string[] args) { Solve(); } private const long MOD = 1000000007; static void Solve() { string s = Console.ReadLine(); string[] table = { "maerd", "remaerd", "esare", "resare" }; var worksz = new StringBuilder(s.Length); for(int i=0;i<s.Length;++i) { worksz.Append(s[s.Length - 1 - i]); } s = worksz.ToString(); bool success = true; int idx = 0; while(true) { if(idx == s.Length) { success = true; break; } string part = s.Substring(idx); bool isMatch = false; foreach(var key in table) { if (part.StartsWith(key)) { isMatch = true; idx += key.Length; } } if( !isMatch) { success = false; break; } } string ans = success ? "YES" : "NO"; Console.WriteLine(ans); } private static string MatchWord(string s, string key, string[] table) { foreach(var t in table) { if(t.StartsWith(key)) { return t; } } return null; } #region よく使う便利関数 private static bool isPrime(long x) { if (x == 2) { return true; } if (x < 2 || x % 2 == 0) { return false; } long i = 3; while (i * i <= x) { if (x % i == 0) { return false; } i = i + 2; } return true; } private static long lcm(long x, long y) { return x / gcd(x, y) * y; } private static long gcd(long x, long y) { return y > 0 ? gcd(y, x % y) : x; } private static long pow(long x, long n) { if (n == 0) { return 1; } long res = pow(x * x % MOD, n / 2); if (n % 2 == 1) { res = res * x % MOD; } return res; } private static int ReadAndParseInt() { return int.Parse(Console.ReadLine()); } private static int[] ReadAndParseIntArr() { return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); } private static long ReadAndParseLong() { return long.Parse(Console.ReadLine()); } private static long[] ReadAndParseLongArr() { return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse); } #endregion } }
Submission Info
Submission Time | |
---|---|
Task | C - Daydream |
User | masakam1 |
Language | C# (Mono 4.6.2.0) |
Score | 300 |
Code Size | 3287 Byte |
Status | AC |
Exec Time | 1105 ms |
Memory | 31644 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | subtask0_0.txt, subtask0_1.txt, subtask0_2.txt |
All | subtask0_0.txt, subtask0_1.txt, subtask0_2.txt, subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_2.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
subtask0_0.txt | AC | 23 ms | 9184 KB |
subtask0_1.txt | AC | 23 ms | 9184 KB |
subtask0_2.txt | AC | 24 ms | 13280 KB |
subtask1_0.txt | AC | 929 ms | 29004 KB |
subtask1_1.txt | AC | 854 ms | 29000 KB |
subtask1_10.txt | AC | 1026 ms | 29616 KB |
subtask1_11.txt | AC | 1002 ms | 29648 KB |
subtask1_12.txt | AC | 1044 ms | 29724 KB |
subtask1_13.txt | AC | 1097 ms | 31644 KB |
subtask1_14.txt | AC | 744 ms | 28980 KB |
subtask1_15.txt | AC | 998 ms | 28956 KB |
subtask1_2.txt | AC | 372 ms | 28944 KB |
subtask1_3.txt | AC | 1105 ms | 28200 KB |
subtask1_4.txt | AC | 1067 ms | 27952 KB |
subtask1_5.txt | AC | 1046 ms | 28216 KB |
subtask1_6.txt | AC | 1037 ms | 29532 KB |
subtask1_7.txt | AC | 1019 ms | 29432 KB |
subtask1_8.txt | AC | 987 ms | 28080 KB |
subtask1_9.txt | AC | 1018 ms | 30280 KB |