結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2016-06-18 03:52:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 138 ms / 1,000 ms |
| コード長 | 1,176 bytes |
| コンパイル時間 | 939 ms |
| コンパイル使用メモリ | 80,452 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-06 22:56:23 |
| 合計ジャッジ時間 | 1,714 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 |
ソースコード
#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];
int m=suf.size();
if (words.size()+3<m) return false;
int n=words.size();
for(int i=n-1; i>=n-4; --i) if (isalnum(words[i])) {
if (i+1<m) return false;
return words.substr(i+1-m, m)==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 and k+1<s.size()) {
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;
}
else {
cout<<"WRONG!"<<endl;
}
}
}
hogeover30