結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-06-16 16:11:35 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,583 bytes |
| コンパイル時間 | 2,577 ms |
| コンパイル使用メモリ | 82,664 KB |
| 実行使用メモリ | 61,324 KB |
| 最終ジャッジ日時 | 2024-11-06 22:33:11 |
| 合計ジャッジ時間 | 6,025 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 3 WA * 5 |
ソースコード
package yukicoder;
import java.io.UnsupportedEncodingException;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
public static void main(String[] args) {
new Main().solver();
}
Set lowcase = new HashSet<>();
Set nonsymbol = new HashSet<>();
byte[] digi;
byte[] petit;
byte[] gema;
byte[] piyo;
@SuppressWarnings("unchecked")
void solver() {
byte[] l = null;
byte[] d = null;
try {
d = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789".getBytes("US-ASCII");
digi = "nyo".getBytes("US-ASCII");
petit = "nyu".getBytes("US-ASCII");
gema = "gema".getBytes("US-ASCII");
piyo = "pyo".getBytes("US-ASCII");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
for (int i = 0; i < d.length; i++) {
nonsymbol.add(d[i]);
}
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String[] s= sc.nextLine().split(" ");
String who=s[0];
String line = "";
for(int i=1;i<s.length;i++){
line+=(s[i]==null?" ":s[i].toLowerCase());
}
if (isCorrect(who, line)) {
System.out.println("CORRECT (maybe)");
} else {
System.out.println("WRONG!");
}
}
}
boolean isCorrect(String who, String line) {
byte[] asciiCodes=null;
if(line==null)return false;
try {
asciiCodes = line.getBytes("US-ASCII");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
if (who.equals("digi")) {
if (bottom(digi, asciiCodes)) {
return true;
}
} else if (who.equals("petit")) {
if (bottom(petit, asciiCodes)) {
return true;
}
} else if (who.equals("rabi")) {
for (int i = 0; i < asciiCodes.length; i++) {
if (nonsymbol.contains(asciiCodes[i])) {
return true;
}
}
} else if (who.equals("gema")) {
if (bottom(gema, asciiCodes)) {
return true;
}
} else if (who.equals("piyo")) {
if (bottom(piyo, asciiCodes)) {
return true;
}
} else {
// throw new AssertionError("who is " + who + " ?");
return false;
}
return false;
}
boolean bottom(byte[] bottom, byte[] code) {
int n = bottom.length;
int len = code.length;
for (int i = 0; i < 4; i++) {
boolean f = false;
for (int j = (len - 1) - (n - 1) - i; j >= 0 && j < len - i; j++) {
f = true;
if (bottom[j - (len - 1) + (n - 1) + i] != code[j]) {
f = false;
break;
}
}
for (int j = len - i; j >= 0 && j < len; j++) {
if (nonsymbol.contains(code[j])) {
f = false;
break;
}
}
if (f) {
return true;
}
}
return false;
}
}