結果

問題 No.380 悪の台本
ユーザー mbanmban
提出日時 2017-01-10 01:06:13
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 3,584 bytes
コンパイル時間 996 ms
コンパイル使用メモリ 109,824 KB
実行使用メモリ 24,704 KB
最終ジャッジ日時 2024-04-24 14:52:50
合計ジャッジ時間 1,902 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;


class Magatro
{
    const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    const string abc = "abcdefghijklmnopqrstuvwxyz";
    static void Main()
    {
        Scanner sc = new Scanner();
        while (true)
        {
            string name = sc.Next();
            string speak = ToSmall(sc.NextLine());

            bool a = false;
            switch (name)
            {
                case "digi":
                    a = last(speak, "nyo");
                    break;
                case "petit":
                    a = last(speak, "nyu");
                    break;
                case "rabi":
                  foreach(char c in abc)
                    {
                        if (speak.Contains(c))
                        {
                            a = true;
                            break;
                        }
                    }
                    a = false;
                    break;
                case "gema":
                    a = last(speak, "gema");
                    break;
                case "piyo":
                    a = last(speak, "pyo");
                    break;
            }
            if (a)
            {
                Console.WriteLine("CORRECT (maybe)");
            }
            else
            {
                Console.WriteLine("WRONG!");
            }
        }
    }
    static bool last(string S,string last)
    {
        int ind = 0;
        if (S.Length < 3)
        {
            return false;
        }
        for(int i = 1; i <= 3; i++)
        {
          if( abc.Contains(S[S.Length - i]))
            {
                break;
            }
            ind++;
        }
        if (S.Length - ind < last.Length)
        {
            return false;
        }
        for(int i = 0; i < last.Length; i++)
        {
            if (S[S.Length - 1 - ind - i] != last[last.Length - i - 1])
            {
                return false;
            }
        }
        return true;
    }
    static string ToSmall(string S)
    {
        char[] C = S.ToArray();
        for(int i = 0; i < C.Length; i++)
        {
            int ind = ABC.IndexOf(C[i]);
            if (ind >= 0)
            {
                C[i] = abc[ind];
            }
        }
        return new string(C);
    }
}

public class Scanner
{
    public string[] S;
    private int Index;
    private char Separator;
    public Scanner(char separator=' ')
    {
        Index = 0;
        Separator = separator;
    }
    public string Next()
    {
        string result;
        if (S == null || Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public string NextLine()
    {
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        List<string> res = new List<string>();
        for(int i = Index; i < S.Length; i++)
        {
            res.Add(S[i]);
        }
        Index = S.Length;
        return string.Join(Separator.ToString(), res.ToArray());
    }
    private string[] Line()
    {
        return Console.ReadLine().Split(Separator);
    } 
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
}
0