結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
14番
|
| 提出日時 | 2016-06-18 04:18:17 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,717 bytes |
| コンパイル時間 | 994 ms |
| コンパイル使用メモリ | 108,032 KB |
| 実行使用メモリ | 21,632 KB |
| 最終ジャッジ日時 | 2024-11-06 22:56:42 |
| 合計ジャッジ時間 | 2,198 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 4 WA * 4 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
class Program
{
public void Proc()
{
Reader.IsDebug = false;
string correct = "CORRECT (maybe)";
string wrong = "WRONG!";
string inpt = string.Empty;
do {
inpt = Reader.ReadLine();
if(inpt == null) {
continue;
}
int pos = inpt.IndexOf(" ");
if(pos < 0) {
Console.WriteLine(wrong);
continue;
}
string name = inpt.Substring(0,pos);
string dialog = inpt.Substring(pos + 1);
string[] names = new string[] {"digi", "petit", "gema", "piyo"};
string[] gobis = new string[] {"nyo", "nyu", "gema", "pyo"};
bool isCorrect = false;
if(name.Equals("rabi")) {
foreach (char c in dialog)
{
if(!this.IsKigou(c)) {
isCorrect = true;
}
}
} else {
int idx = -1;
for(int i=0; i<names.Length; i++) {
if(names[i].Equals(name)) {
idx = i;
}
}
if(idx < 0) {
Console.WriteLine(wrong);
continue;
}
if(!dialog.Contains(gobis[idx])) {
Console.WriteLine(wrong);
continue;
}
if(dialog.EndsWith(gobis[idx])) {
Console.WriteLine(correct);
continue;
}
string last = dialog.Split(new string[]{gobis[idx]}, StringSplitOptions.None).Last();
if(last.Length > 3) {
Console.WriteLine(wrong);
continue;
}
if(!this.ContainsNotKigou(last)) {
isCorrect = true;
}
}
if(isCorrect) {
Console.WriteLine(correct);
} else
{
Console.WriteLine(wrong);
}
} while (inpt != null);
}
private bool ContainsNotKigou(String str) {
foreach (char item in str)
{
if(!IsKigou(item)) {
return true;
}
}
return false;
}
private bool IsKigou(char c) {
if(c >= 'a' && c <= 'z') {
return false;
} else if(c >= 'A' && c <= 'Z') {
return false;
} else if(c >= '0' && c <= '9')
{
return false;
}
return true;
}
public class Reader
{
public static bool IsDebug = true;
private static String PlainInput = @"
piyo pyopyo!!!
petit nyu!!!!
gema
diginyo
digi nyo
gema gema
gema gemaa
petit nyuo
gema gema1
petit nyu3
petit nyunyo
petit nyu !
petit nyu!
putit tigau nyu
petit nyu!
petit nyu!
1
2
3
4
5
6
7
!
@
#
$
%
rabi a
rabi !
rabi 1
rabi $
rabi nyu
rabi rabi
rabi !($&!*$%&[[]+_+}{
petiT nyu
petit nyu
";
private static System.IO.StringReader Sr = null;
public static string ReadLine()
{
if (IsDebug)
{
if (Sr == null)
{
Sr = new System.IO.StringReader(PlainInput.Trim());
}
return Sr.ReadLine();
}
else
{
return Console.ReadLine();
}
}
}
static void Main()
{
Program prg = new Program();
prg.Proc();
}
}
14番