結果
| 問題 | 
                            No.380 悪の台本
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2016-09-02 21:37:34 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 559 ms / 1,000 ms | 
| コード長 | 1,227 bytes | 
| コンパイル時間 | 2,210 ms | 
| コンパイル使用メモリ | 77,548 KB | 
| 実行使用メモリ | 51,652 KB | 
| 最終ジャッジ日時 | 2024-11-06 23:13:26 | 
| 合計ジャッジ時間 | 5,905 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 8 | 
ソースコード
import java.util.Scanner;
import java.io.IOException;
import java.io.PrintWriter;
public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		String[] name = {"digi","petit","rabi","gema","piyo"};//TLE防止		
		
		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){
				out.println(W);
				continue;
			}
			
			String sub = line.split(" ",2)[0];
			
			for(int i=0; i<5; i++){
				if(sub.equals(name[i])){
					flag = true;
				    if(line.matches(check[i])){	
				    	out.println(C);
				        break;
				    }else{
				    	out.println(W);
				    	break;
				    }
				}
			}
			if(!flag){
				out.println(W);
			}else{
				flag = false;
			}
		}
		sc.close();
		out.flush();
	}
}