結果

問題 No.380 悪の台本
ユーザー 14番14番
提出日時 2016-06-18 04:21:09
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 271 ms / 1,000 ms
コード長 3,551 bytes
コンパイル時間 2,300 ms
コンパイル使用メモリ 103,304 KB
実行使用メモリ 24,284 KB
最終ジャッジ日時 2023-08-06 19:52:34
合計ジャッジ時間 4,013 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
22,004 KB
testcase_01 AC 81 ms
22,124 KB
testcase_02 AC 81 ms
24,284 KB
testcase_03 AC 81 ms
22,096 KB
testcase_04 AC 91 ms
24,124 KB
testcase_05 AC 113 ms
22,156 KB
testcase_06 AC 106 ms
24,184 KB
testcase_07 AC 271 ms
23,224 KB
testcase_08 AC 72 ms
24,028 KB
testcase_09 AC 89 ms
24,256 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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();
    }
}
0