結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-02 17:42:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,405 bytes |
| コンパイル時間 | 1,086 ms |
| コンパイル使用メモリ | 78,620 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-10-01 21:05:24 |
| 合計ジャッジ時間 | 2,478 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 WA * 4 RE * 2 |
ソースコード
#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);
}
vector<string> split(string str, char del = ' '){
vector<string> ret;
string cutoff = "";
for(int i = 0; i < str.length(); i++){
if(str[i] == del){
if(cutoff != "") ret.push_back(cutoff);
cutoff = "";
}else{
cutoff += str[i];
}
}
if(cutoff != "") ret.push_back(cutoff);
return ret;
}
string people[5] = {"digi", "petit", "gema", "piyo", "rabi"};
string suffix[4] = {"nyo", "nyu", "gema", "pyo"};
int main(){
string s;
while(getline(cin, s)){
vector<string> line = split(s);
int person;
for(person = 0; person < 5; person++){
if(line[0] == people[person]) break;
}
if(person == 5){
cout << "WRONG!" << endl;
continue;
}
if(person == 4){
bool judge = false;
for(int i = 1; i < line.size(); i++){
for(int j = 0; j < line[i].size(); j++){
if(isSymbol(line[i][j])) judge = true;
}
}
print(judge, "CORRECT (maybe)", "WRONG!");
continue;
}
string last = line[line.size()-1];
print(check(last, suffix[person]) ,"CORRECT (maybe)", "WRONG!");
}
return 0;
}