結果
問題 |
No.380 悪の台本
|
ユーザー |
|
提出日時 | 2019-08-26 19:25:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 135 ms / 1,000 ms |
コード長 | 1,588 bytes |
コンパイル時間 | 2,162 ms |
コンパイル使用メモリ | 207,104 KB |
最終ジャッジ日時 | 2025-01-07 15:20:13 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; bool issign(char c) { return !isalpha(c)&&!isdigit(c); } string tolowers(string s) { for (char& c:s) c=tolower(c); return s; } int main() { string s; map<string,string> guys={{"digi","nyo"},{"petit","nyu"},{"rabi",""},{"gema","gema"},{"piyo","pyo"}}; while (getline(cin,s)) { int n=s.size(); int i=0; string name; while (i<n&&s[i]!=' ') { name+=s[i]; i++; } if (guys.find(name)==guys.end()) { puts("WRONG!"); continue; } i++; if (n<=i) { puts("WRONG!"); continue; } s=s.substr(i); if (name=="rabi") { bool f=0; for (char c:s) { if (isalpha(c)||isdigit(c)) { f=1; break; } } if (f) puts("CORRECT (maybe)"); else puts("WRONG!"); continue; } int r=s.size(); r--; int cnt=0; while (0<=r&&issign(s[r])) { cnt++; r--; } if (cnt>3) { puts("WRONG!"); continue; } string suf=guys[name]; int l=r-suf.size()+1; if (l<0) { puts("WRONG!"); continue; } if (tolowers(s.substr(l,suf.size()))==suf) { puts("CORRECT (maybe)"); } else { puts("WRONG!"); } } return 0; }