結果
問題 | No.380 悪の台本 |
ユーザー |
![]() |
提出日時 | 2016-06-17 23:29:38 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 134 ms / 1,000 ms |
コード長 | 1,399 bytes |
コンパイル時間 | 1,364 ms |
コンパイル使用メモリ | 160,736 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-06 22:41:49 |
合計ジャッジ時間 | 2,111 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 |
ソースコード
#include <bits/stdc++.h>bool check(std::string& str, std::string t, int remain) {if( str.size() < t.size() ) return false;bool b = true;for(int i = 0; i < (int)t.size(); ++i) {if( toupper(str[str.size()-t.size()+i]) != toupper(t[i]) ) {b = false;break;}}if( b ) return true;if( remain <= 0 ) return false;char c = str[str.size()-1];if( isalnum(c) ) return false;str.pop_back();return check(str, t, remain - 1);}int main() {for(;;) {std::string name, str, temp;if( not std::getline(std::cin, temp) ) break;for(int i = 0; i < (int)temp.size(); ++i) {if( temp[i] != ' ' ) {name += temp[i];}else {for(int j = i; j < (int)temp.size(); ++j) {str += temp[j];}goto label_1;}}label_1:;//if( not ( std::cin >> name ) ) break;//std::getline(std::cin, str);bool res = false;if( name == "digi" ) res = check(str, "nyo", 3);if( name == "petit" ) res = check(str, "nyu", 3);if( name == "gema" ) res = check(str, "gema", 3);if( name == "piyo" ) res = check(str, "pyo", 3);if( name == "rabi" ) {bool b = false;for(int i = 0; i < (int)str.size(); ++i) {if( isalnum(str[i]) ) b = true;}res = b;}printf("%s\n", res ? "CORRECT (maybe)" : "WRONG!");}return 0;}