結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
どらら
|
| 提出日時 | 2016-06-18 00:17:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,461 bytes |
| コンパイル時間 | 931 ms |
| コンパイル使用メモリ | 84,824 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-06 22:50:23 |
| 合計ジャッジ時間 | 1,613 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 4 WA * 4 |
ソースコード
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
bool prefix_check(const string& prefix, const string& str){
if(prefix.size() > str.size()) return false;
rep(i,prefix.size()){
if(str[i]!=prefix[i]) return false;
}
return true;
}
bool is_symbol(char c){
if((' '<=c && c<='/') ||
(':'<=c && c<='@') ||
('['<=c && c<='`') ||
('{'<=c && c<='~')){
return true;
}
return false;
}
bool suffix_check(int st, const string& suffix, const string& str){
if(str.size()-st < suffix.size()) return false;
if(str.size()-suffix.size()>=st){
bool flg = true;
rep(i,suffix.size()){
int offset = str.size()-suffix.size();
if(suffix[i] != str[offset+i]) flg = false;
}
if(flg) return true;
}
if(str.size()-suffix.size()-1>=st){
bool flg = true;
rep(i,suffix.size()){
int offset = str.size()-suffix.size()-1;
if(suffix[i] != str[offset+i]) flg = false;
}
if(!is_symbol(str[str.size()-1])) flg = false;
if(flg) return true;
}
if(str.size()-suffix.size()-2>=st){
bool flg = true;
rep(i,suffix.size()){
int offset = str.size()-suffix.size()-2;
if(suffix[i] != str[offset+i]) flg = false;
}
if(!is_symbol(str[str.size()-1])) flg = false;
if(!is_symbol(str[str.size()-2])) flg = false;
if(flg) return true;
}
if(str.size()-suffix.size()-3>=st){
bool flg = true;
rep(i,suffix.size()){
int offset = str.size()-suffix.size()-3;
if(suffix[i] != str[offset+i]) flg = false;
}
if(!is_symbol(str[str.size()-1])) flg = false;
if(!is_symbol(str[str.size()-2])) flg = false;
if(!is_symbol(str[str.size()-3])) flg = false;
if(flg) return true;
}
return false;
}
bool include_char(int st, const string& str){
REP(i,st,str.size()){
if(is_symbol(str[i])) return true;
}
return false;
}
int main(){
string str;
while(getline(cin, str)){
bool flg = false;
if(prefix_check("digi ", str)){
string foo = str;
std::transform(foo.begin(), foo.end(), foo.begin(), ::tolower);
if(suffix_check(5, "nyo", foo)) flg = true;
}
else if(prefix_check("petit ", str)){
string foo = str;
std::transform(foo.begin(), foo.end(), foo.begin(), ::tolower);
if(suffix_check(6, "nyu", foo)) flg = true;
}
else if(prefix_check("rabi ", str)){
string foo = str;
std::transform(foo.begin(), foo.end(), foo.begin(), ::tolower);
if(include_char(5, foo)) flg = true;
}
else if(prefix_check("gema ", str)){
string foo = str;
std::transform(foo.begin(), foo.end(), foo.begin(), ::tolower);
if(suffix_check(5, "gema", foo)) flg = true;
}
else if(prefix_check("piyo ", str)){
string foo = str;
std::transform(foo.begin(), foo.end(), foo.begin(), ::tolower);
if(suffix_check(5, "pyo", foo)) flg = true;
}
if(flg){
cout << "CORRECT (maybe)" << endl;
}else{
cout << "WRONG!" << endl;
}
}
return 0;
}
どらら