結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
14番
|
| 提出日時 | 2016-06-18 04:21:09 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 260 ms / 1,000 ms |
| コード長 | 3,551 bytes |
| コンパイル時間 | 3,751 ms |
| コンパイル使用メモリ | 106,496 KB |
| 実行使用メモリ | 21,888 KB |
| 最終ジャッジ日時 | 2024-11-06 22:56:47 |
| 合計ジャッジ時間 | 2,183 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 |
コンパイルメッセージ
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.ToLower().Contains(gobis[idx])) {
Console.WriteLine(wrong);
continue;
}
if(dialog.ToLower().EndsWith(gobis[idx])) {
Console.WriteLine(correct);
continue;
}
string last = dialog.ToLower().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 = @"
digi correct-da-nyo
digi KOREMO CORRECT DA NYO
digi KoReDeMo Correct NanDa Nyo!!
petit putit ha digi ja nai nyo
";
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番