結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-04 10:51:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,929 bytes |
| コンパイル時間 | 782 ms |
| コンパイル使用メモリ | 75,212 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 22:19:43 |
| 合計ジャッジ時間 | 1,763 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 WA * 6 |
ソースコード
// 相当めんどくさい、空白の処理やらなにやら
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define print(x, a, b) if(x) cout << a << endl; else cout << b << endl
bool isSymbol(char x){
bool small = 'a' <= x && x <= 'z';
bool large = 'A' <= x && x <= 'Z';
bool number = '0' <= x && x <= '9';
if(small || large || number) return false;
else return true;
}
bool startsWith(string str, string pre){
int s = str.length(), p = pre.length();
if(s < p) return false;
int j;
for(j = 0; j < p; j++){
if(str[j] != pre[j]) break;
}
return j == p;
}
bool check(string s, string gobi){
reverse(s.begin(), s.end());
reverse(gobi.begin(), gobi.end());
int pos = 0;
while(pos < s.length() && isSymbol(s[pos])){
pos++;
}
if(pos > 3) return false;
bool judge = true;
for(int i = 0; i < 3; i++){
if(pos+i > s.length()-1 || isSymbol(s[pos+i])) judge = false;
else s[pos+i] = tolower(s[pos+i]);
}
if(!judge) return false;
return startsWith(s.substr(pos), gobi);
}
string people[5] = {"digi ", "petit ", "gema ", "piyo ", "rabi "};
string suffix[4] = {"nyo", "nyu", "gema", "pyo"};
int main(){
string s;
while(getline(cin, s)){
int person;
for(person = 0; person < 5; person++){
if(startsWith(s, people[person])) break;
}
if(person == 5){
cout << "WRONG!" << endl;
continue;
}
if(person == 4){
bool judge = false;
for(int i = 0; i < s.size(); i++){
if(!isSymbol(s[i])) judge = true;
}
print(judge, "CORRECT (maybe)", "WRONG!");
continue;
}
print(check(s, suffix[person]) ,"CORRECT (maybe)", "WRONG!");
}
return 0;
}