結果

問題 No.380 悪の台本
ユーザー ym678ym678
提出日時 2016-08-31 19:41:36
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,292 bytes
コンパイル時間 2,119 ms
コンパイル使用メモリ 77,988 KB
実行使用メモリ 54,276 KB
最終ジャッジ日時 2024-04-24 14:46:16
合計ジャッジ時間 6,261 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,152 KB
testcase_01 WA -
testcase_02 AC 130 ms
41,304 KB
testcase_03 AC 131 ms
40,984 KB
testcase_04 AC 382 ms
47,996 KB
testcase_05 AC 534 ms
48,004 KB
testcase_06 WA -
testcase_07 AC 987 ms
54,276 KB
testcase_08 AC 228 ms
43,036 KB
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		String[] name = {"digi","petit","rabi","gema","piyo"}; 		
		
		String[] check = new String[5];
		check[0] = "digi .*[nN][yY][oO]([^a-zA-Z0-9]{0,3})$";
		check[1] = "petit .*[nN][yY][uU]([^a-zA-Z0-9]{0,3})$";
		check[2] = "rabi .*[a-zA-Z0-9].*";
		check[3] = "gema .*[gG][eE][mM][aA]([^a-zA-Z0-9]{0,3})$";
		check[4] = "piyo .*[pP][yY][oO]([^a-zA-Z0-9]{0,3})$";
		
		String C = "CORRECT (maybe)";
		String W = "WRONG!";
		boolean flag = false;
		while(sc.hasNextLine()){
			String line = sc.nextLine();
			if(line.indexOf(' ') == -1){
				System.out.println(W);
				continue;
			}
			String sub = line.split(" ",2)[0];
			for(int i=0; i<5; i++){
				if(sub.equals(name[i])){
					flag = true;
					Pattern p = Pattern.compile(check[i]);
					Matcher m = p.matcher(line);
					boolean b = m.matches();
				    if(b){				    	
				    	System.out.println(C);
				        break;
				    }else{
				    	System.out.println(W);
				    	break;
				    }
				}
			}
			if(!flag){
				System.out.println(W);
			}
		}
		sc.close();
		System.out.flush();
	}
}
0