結果

問題 No.380 悪の台本
ユーザー 14番14番
提出日時 2016-06-18 04:18:17
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 3,717 bytes
コンパイル時間 911 ms
コンパイル使用メモリ 107,904 KB
実行使用メモリ 21,632 KB
最終ジャッジ日時 2024-04-24 14:32:31
合計ジャッジ時間 1,931 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
18,816 KB
testcase_01 AC 28 ms
19,200 KB
testcase_02 WA -
testcase_03 AC 29 ms
19,072 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 249 ms
17,920 KB
testcase_08 AC 28 ms
19,072 KB
testcase_09 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.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();
    }
}
0