結果
問題 | No.380 悪の台本 |
ユーザー | 0w1 |
提出日時 | 2016-11-29 16:26:05 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 139 ms / 1,000 ms |
コード長 | 2,621 bytes |
コンパイル時間 | 1,711 ms |
コンパイル使用メモリ | 174,104 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-06 23:18:09 |
合計ジャッジ時間 | 2,490 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,248 KB |
testcase_03 | AC | 2 ms
5,248 KB |
testcase_04 | AC | 10 ms
5,248 KB |
testcase_05 | AC | 20 ms
5,248 KB |
testcase_06 | AC | 19 ms
5,248 KB |
testcase_07 | AC | 139 ms
5,248 KB |
testcase_08 | AC | 4 ms
5,248 KB |
testcase_09 | AC | 10 ms
5,248 KB |
ソースコード
#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; }