結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
eitaho
|
| 提出日時 | 2016-06-17 22:49:32 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 3,526 bytes |
| コンパイル時間 | 977 ms |
| コンパイル使用メモリ | 110,080 KB |
| 実行使用メモリ | 23,296 KB |
| 最終ジャッジ日時 | 2024-11-06 22:37:34 |
| 合計ジャッジ時間 | 2,370 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 WA * 6 RE * 1 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;
public class Program
{
static readonly string OK = "CORRECT (maybe)";
static readonly string NG = "WRONG!";
static readonly string[] Characters = { "digi", "petit", "rabi", "gema", "piyo" };
Regex[] reg;
bool[] isK;
string K;
public void Solve()
{
K = "";
isK = new bool[256];
for (char c = (char)32; c < 127; c++)
if (!char.IsDigit(c) && !char.IsLetter(c))
{
K += c;
isK[c] = true;
}
reg = new Regex[Characters.Length];
reg[0] = new Regex("nyo[" + K + "?]{0,3}$");
reg[1] = new Regex("nyu[" + K + "?]{0,3}$");
reg[3] = new Regex("gema[" + K + "?]{0,3}$");
reg[4] = new Regex("pyo[" + K + "?]{0,3}$");
string S;
while (!string.IsNullOrEmpty(S = Console.ReadLine()))
{
int who = 0;
for (; who < Characters.Length; who++)
if (S.StartsWith(Characters[who]))
{
string sub = S.Substring(Characters[who].Length + 1).ToLower();
Console.WriteLine(Valid(sub, who) ? OK : NG);
break;
}
if (who == Characters.Length) Console.WriteLine(NG);
}
}
private bool Valid(string S, int who)
{
if (who == 2)
{
int count = 0;
foreach (char c in S) if (isK[c] && ++count > 1) return false;
return count == 1;
}
return reg[who].IsMatch(S);
}
}
class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
static TextReader reader = Console.In;
static readonly char[] separator = { ' ' };
static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
static string[] A = new string[0];
static int i;
static void Init() { A = new string[0]; }
public static void Set(TextReader r) { reader = r; Init(); }
public static void Set(string file) { reader = new StreamReader(file); Init(); }
public static bool HasNext() { return CheckNext(); }
public static string String() { return Next(); }
public static int Int() { return int.Parse(Next()); }
public static long Long() { return long.Parse(Next()); }
public static double Double() { return double.Parse(Next()); }
public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
public static int[] IntArray(int N) { return Range(N, Int); }
public static int[][] IntTable(int H) { return Range(H, IntLine); }
public static string[] StringArray(int N) { return Range(N, Next); }
public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
public static string Line() { return reader.ReadLine().Trim(); }
static T[] Range<T>(int N, Func<T> f) { return Enu.Range(0, N).Select(i => f()).ToArray(); }
static string[] Split(string s) { return s.Split(separator, op); }
static string Next() { CheckNext(); return A[i++]; }
static bool CheckNext()
{
if (i < A.Length) return true;
string line = reader.ReadLine();
if (line == null) return false;
if (line == "") return CheckNext();
A = Split(line);
i = 0;
return true;
}
}
eitaho