結果

問題 No.380 悪の台本
ユーザー mbanmban
提出日時 2017-01-10 03:14:24
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 271 ms / 1,000 ms
コード長 3,789 bytes
コンパイル時間 849 ms
コンパイル使用メモリ 110,080 KB
実行使用メモリ 24,576 KB
最終ジャッジ日時 2024-04-24 14:53:16
合計ジャッジ時間 2,002 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
18,560 KB
testcase_01 AC 24 ms
18,816 KB
testcase_02 AC 24 ms
18,816 KB
testcase_03 AC 24 ms
18,688 KB
testcase_04 AC 37 ms
20,992 KB
testcase_05 AC 61 ms
22,784 KB
testcase_06 AC 57 ms
22,912 KB
testcase_07 AC 271 ms
22,656 KB
testcase_08 AC 45 ms
24,576 KB
testcase_09 AC 46 ms
22,912 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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;


class Magatro
{
    const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    const string abc = "abcdefghijklmnopqrstuvwxyz";
    const string not = "abcdefghijklmnopqrstuvwxyz 1234567890";
    static void Main()
    {
        using(var sr=new StreamReader(Console.OpenStandardInput()))
        {
            while (!sr.EndOfStream)
            {
                string s = sr.ReadLine();
                string[] ss = s.Split(' ');
                string name = ss[0];
                List<string> sp = new List<string>();
                for(int i = 1; i < ss.Length; i++)
                {
                    sp.Add(ss[i]);
                }
                string speak =ToSmall( string.Join(" ", sp.ToArray()));
                Console.WriteLine(ans(name, speak));
          //      Console.WriteLine("{1}", name, speak);
            }
        }
      
           
    }
    static string ans(string name,string speak)
    {
        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 not)
                {
                    if (speak.Contains(c))
                    {
                        a = true;
                        break;
                    }
                }
                if (a)
                {
                    break;
                }
                a = false;
                break;
            case "gema":
                a = last(speak, "gema");
                break;
            case "piyo":
                a = last(speak, "pyo");
                break;

        }
        if (a)
        {
            return("CORRECT (maybe)");
        }
        else
        {
            return("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( not.Contains(S[S.Length - i])&&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;
    }
    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