結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-04-18 16:29:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 126 ms / 1,000 ms |
| コード長 | 1,637 bytes |
| コンパイル時間 | 1,049 ms |
| コンパイル使用メモリ | 90,192 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-04-18 16:29:41 |
| 合計ジャッジ時間 | 2,023 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 |
ソースコード
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <sstream>
using namespace std;
bool isSymbol(char c) {
return !('0' <= c && c <= '9') && !('a' <= c && c <= 'z');
}
bool check(string s, string gobi) {
if(s.size() < gobi.size()) return false;
for(int i = 0; i <= 3; i++) {
if(s.size() < gobi.size() + i) continue;
if(s.substr(s.size() - gobi.size() - i, gobi.size()) != gobi)
continue;
bool flag = true;
for(int j = 0; j < i; j++) {
int p = s.size() - 1 - j;
if(!isSymbol(s[p])) {
flag = false;
break;
}
}
if(flag) return true;
}
return false;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string name, s, t;
while(getline(cin, t)) {
bool ok = false;
if(t.size() >= 5 && t[4] == ' ') {
name = t.substr(0, 4);
s = t.substr(5);
for(int i = 0; i < s.size(); i++) {
if('A' <= s[i] && s[i] <= 'Z')
s[i] = tolower(s[i]);
}
if(name == "digi") {
ok = check(s, "nyo");
}
if(name == "rabi") {
for(int i = 0; i < s.size(); i++) {
if(!isSymbol(s[i])) {
ok = true;
}
}
}
if(name == "gema") {
ok = check(s, "gema");
}
if(name == "piyo") {
ok = check(s, "pyo");
}
}
if(t.size() >= 6 && t[5] == ' ') {
name = t.substr(0, 5);
s = t.substr(5);
for(int i = 0; i < s.size(); i++) {
if('A' <= s[i] && s[i] <= 'Z')
s[i] = tolower(s[i]);
}
if(name == "petit") {
ok = check(s, "nyu");
}
}
if(ok) {
cout << "CORRECT (maybe)" << endl;
}
else {
cout << "WRONG!" << endl;
}
}
}
vjudge1