結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
neko_the_shadow
|
| 提出日時 | 2019-05-17 16:44:53 |
| 言語 | Java (openjdk 23) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,102 bytes |
| コンパイル時間 | 1,976 ms |
| コンパイル使用メモリ | 78,220 KB |
| 実行使用メモリ | 56,048 KB |
| 最終ジャッジ日時 | 2024-09-17 05:57:22 |
| 合計ジャッジ時間 | 3,909 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 4 WA * 1 RE * 3 |
ソースコード
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
public class Main {
public static void main(String[] args) throws IOException {
Set<Character> letters = new HashSet<>();
for (char ch = 'a'; ch <= 'z'; ch++) letters.add(ch);
for (char ch = 'A'; ch <= 'Z'; ch++) letters.add(ch);
for (char ch = '0'; ch <= '9'; ch++) letters.add(ch);
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = stdin.readLine()) != null) {
String[] tokens = line.split(" ", 2);
String who = tokens[0];
StringBuilder speech = new StringBuilder();
for (char c : tokens[1].toCharArray()) {
if (letters.contains(c)) {
speech.append(c);
}
}
String ans = isOK(who, speech.toString().toLowerCase()) ? "CORRECT (maybe)" : "WRONG!";
System.out.println(ans);
}
}
public static boolean isOK(String who, String speech) {
// digiの全てのセリフはnyoか,nyoの末尾に記号を1~3文字つけたもので終わる
// petitの全てのセリフはnyuか,nyuの末尾に記号を1~3文字つけたもので終わる
// gemaの全てのセリフはgemaか,gemaの末尾に記号を1~3文字つけたもので終わる
// piyoの全てのセリフはpyoか,pyoの末尾に記号を1~3文字つけたもので終わる
if (who.equals("digi")) return speech.endsWith("nyo");
if (who.equals("petit")) return speech.endsWith("nyu");
if (who.equals("gema")) return speech.endsWith("gema");
if (who.equals("piyo")) return speech.endsWith("pyo");
// rabiの全てのセリフは記号でない文字を少なくても1文字含む
// 変数speechは記号文字はすべて削除されている。
return !speech.isEmpty();
}
}
neko_the_shadow