結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2018-03-11 16:40:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,914 bytes |
| コンパイル時間 | 1,505 ms |
| コンパイル使用メモリ | 172,456 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-15 00:18:59 |
| 合計ジャッジ時間 | 3,845 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 WA * 1 RE * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))
using ll = long long;
using P = std::tuple<int,int>;
const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
string line;
bool isSymbol(char c){
return !isalnum(c);
}
bool isDialogueWith(string str, string suffix){
int s = str.size() - 1;
while(s >= 0 && isSymbol(str[s])){
--s;
}
int s_cnt = str.size() - 1 - s;
if(s_cnt > 3){
return false;
}
string tail = str.substr(s - suffix.size() + 1, suffix.size());
return tail == suffix;
}
bool isValid(){
if(line.size() < 5){
return false;
}
if(line.substr(0, 5) == "digi "){
return isDialogueWith(line.substr(5), "nyo");
}else if(line.substr(0, 5) == "rabi "){
string tail = line.substr(5);
return any_of(tail.begin(), tail.end(), [](char c){
return isalnum(c);
});
}else if(line.substr(0, 5) == "gema "){
return isDialogueWith(line.substr(5), "gema");
}else if(line.substr(0, 5) == "piyo "){
return isDialogueWith(line.substr(5), "pyo");
}else if(line.size() >= 6 && line.substr(0, 6) == "petit "){
return isDialogueWith(line.substr(6), "nyu");
}
return false;
}
int main(){
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
while(true){
getline(cin, line);
if(cin.eof()){
break;
}
transform(line.begin(), line.end(), line.begin(), [](char c){
return tolower(c);
});
if(isValid()){
std::cout << "CORRECT (maybe)" << std::endl;
}else{
std::cout << "WRONG!" << std::endl;
}
}
}
tottoripaper