結果
| 問題 |
No.380 悪の台本
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-29 16:21:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,620 bytes |
| コンパイル時間 | 1,799 ms |
| コンパイル使用メモリ | 174,160 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-06 23:17:54 |
| 合計ジャッジ時間 | 2,542 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | AC * 2 WA * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const string msg[] = { "WRONG!", "CORRECT(maybe)" };
const string pn[] = { "digi", "petit", "rabi", "gema", "piyo" };
int sym( const string &s ){
for( int i = 0; i < s.size(); ++i ){
if( 'a' <= s[ i ] and s[ i ] <= 'z' )
return 0;
if( 'A' <= s[ i ] and s[ i ] <= 'Z' )
return 0;
if( '0' <= s[ i ] and s[ i ] <= '9' )
return 0;
}
return 1;
}
signed main(){
string buff;
while( getline( cin, buff ) ){
if( buff.empty() or buff[ 0 ] == ' ' ){
cout << msg[ 0 ] << endl;
continue;
}
stringstream ss( buff );
string s;
int p = 0;
string name;
int ng = 0;
while( ss >> s ){
if( p == 0 ){
name = s;
int ok = 0;
for( int i = 0; i < 5; ++i )
ok |= name == pn[ i ];
ng |= not ok;
break;
}
++p;
}
for( int i = 0; i < buff.size(); ++i )
if( 'A' <= buff[ i ] and buff[ i ] <= 'Z' )
buff[ i ] = buff[ i ] - 'A' + 'a';
if( name.empty() ){
cout << msg[ 0 ] << endl;
continue;
}
string z = buff.substr( name.size() );
if( name == pn[ 0 ] ){
// string z = buff;
int ok = 0;
for( int i = 0; i + 3 <= z.size(); ++i )
if( z.substr( i, 3 ) == "nyo" and sym( z.substr( i + 3 ) ) )
ok |= ( int ) z.size() - ( i + 3 ) <= 3;
ng |= not ok;
} else if( name == pn[ 1 ] ){
// string z;
// for( int i = 0; i < dict.size(); ++i )
// z += dict[ i ];
int ok = 0;
for( int i = 0; i + 3 <= z.size(); ++i )
if( z.substr( i, 3 ) == "nyu" and sym( z.substr( i + 3 ) ) )
ok |= ( int ) z.size() - ( i + 3 ) <= 3;
ng |= not ok;
} else if( name == pn[ 2 ] ){
// string z;
// for( int i = 0; i < dict.size(); ++i )
int ok = 0;
for( int i = 0; i < z.size(); ++i )
ok |= 'a' <= z[ i ] and z[ i ] <= 'z',
ok |= 'A' <= z[ i ] and z[ i ] <= 'z',
ok |= '0' <= z[ i ] and z[ i ] <= '9';
ng |= not ok;
} else if( name == pn[ 3 ] ){
int ok = 0;
for( int i = 0; i + 4 <= z.size(); ++i )
if( z.substr( i, 4 ) == "gema" and sym( z.substr( i + 4 ) ) )
ok |= ( int ) z.size() - ( i + 4 ) <= 3;
ng |= not ok;
} else if( name == pn[ 4 ] ){
int ok = 0;
for( int i = 0; i + 3 <= z.size(); ++i )
if( z.substr( i, 3 ) == "pyo" and sym( z.substr( i + 3 ) ) )
ok |= ( int ) z.size() - ( i + 3 ) <= 3;
ng |= not ok;
}
cout << msg[ not name.empty() and not ng ] << endl;
}
return 0;
}