結果

問題 No.380 悪の台本
ユーザー jp_stejp_ste
提出日時 2016-08-06 18:27:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 597 ms / 1,000 ms
コード長 1,415 bytes
コンパイル時間 2,323 ms
コンパイル使用メモリ 77,796 KB
実行使用メモリ 53,784 KB
最終ジャッジ日時 2024-04-24 14:43:20
合計ジャッジ時間 5,619 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,144 KB
testcase_01 AC 134 ms
41,660 KB
testcase_02 AC 130 ms
41,032 KB
testcase_03 AC 127 ms
41,140 KB
testcase_04 AC 327 ms
47,972 KB
testcase_05 AC 454 ms
49,292 KB
testcase_06 AC 381 ms
48,056 KB
testcase_07 AC 597 ms
53,784 KB
testcase_08 AC 205 ms
43,164 KB
testcase_09 AC 336 ms
47,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    
    static Scanner scan = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        String names[] = { "digi", "petit", "rabi", "gema", "piyo" };
        
        String reges[] = new String[5];
        reges[0] = "digi .*[nN][yY][oO][ -/:-@\\[-\\`\\{-\\~]{0,3}$";
        reges[1] = "petit .*[nN][yY][uU][ -/:-@\\[-\\`\\{-\\~]{0,3}$";
        reges[2] = "rabi .*[a-z0-9A-Z].*";
        reges[3] = "gema .*[gG][eE][mM][aA][ -/:-@\\[-\\`\\{-\\~]{0,3}$";
        reges[4] = "piyo .*[pP][yY][oO][ -/:-@\\[-\\`\\{-\\~]{0,3}$";
        
        while(scan.hasNextLine()) {
            String line = scan.nextLine();
            String name = line.split(" ", 2)[0];
            String str = "WRONG!";
            
            for(int i=0; i<names.length; i++) {
                if(name.equals(names[i])) {
                    Pattern p = Pattern.compile(reges[i]);
                    Matcher m = p.matcher(line);
                    if(m.find()) {
                        str = "CORRECT (maybe)";
                    }
                    break;    
                }
            }
            out.println(str);
        }
        out.flush();
    }
}
0