結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2016-06-18 01:34:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,064 bytes |
| コンパイル時間 | 1,042 ms |
| コンパイル使用メモリ | 80,384 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-06 22:55:26 |
| 合計ジャッジ時間 | 2,173 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 WA * 2 RE * 4 |
ソースコード
#include <iostream>
#include <string>
#include <map>
#include <cctype>
using namespace std;
map<string, string> suffix;
bool correct(const string& words, const string& name)
{
if (name=="rabi") {
for(auto& c: words) if (isalnum(c)) return true;
return false;
}
if (!suffix.count(name)) return false;
string suf=suffix[name];
if (words.size()+3<suf.size()) return false;
int n=words.size();
for(int i=n-1; i>=n-4; --i) if (isalnum(words[i]))
return words.substr(i+1-suf.size(), suf.size())==suf;
return false;
}
int main()
{
string names[]={"digi", "petit", "gema", "piyo"};
string suffs[]={"nyo", "nyu", "gema", "pyo"};
for(int i=0; i<4; ++i) suffix[names[i]]=suffs[i];
string s;
while (getline(cin, s)) {
auto k=s.find(' ');
if (k!=s.npos) {
string name=s.substr(0, k);
string words=s.substr(k+1);
for(auto& c: words) c=tolower(c);
cout<<(correct(words, name) ? "CORRECT (maybe)" : "WRONG!")<<endl;
}
}
}
hogeover30