結果

問題 No.380 悪の台本
ユーザー beetbeet
提出日時 2019-04-19 16:55:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,523 bytes
コンパイル時間 2,515 ms
コンパイル使用メモリ 217,456 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 17:41:20
合計ジャッジ時間 3,541 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 9 ms
4,348 KB
testcase_05 AC 20 ms
4,348 KB
testcase_06 AC 20 ms
4,348 KB
testcase_07 AC 135 ms
4,348 KB
testcase_08 AC 5 ms
4,348 KB
testcase_09 AC 10 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  string str;
  map<string, string> ch;
  ch["digi"]="nyo";
  ch["petit"]="nyu";
  ch["rabi"]="a";
  ch["gema"]="gema";
  ch["piyo"]="pyo";

  auto YES=[](){cout<<"CORRECT (maybe)\n";};
  auto NO=[](){cout<<"WRONG!\n";};      
  auto is_symbol=
    [](char c){
      if(isalpha(c)) return false;
      if(isdigit(c)) return false;       
      return true;
    };
    
  while(getline(cin,str)){
    if(str.size()==0u||str==string(str.size(),' ')){
      NO();
      continue;
    }
    if(count(str.begin(),str.end(),' ')==0){
      //assert(0);
      NO();
      continue;
    }
    stringstream ss(str);
    string name;
    ss>>name;  
    if(!ch.count(name)){
      NO();
      continue;
    }    
    string tmp=str.substr(name.size());
    string s;
    for(char c:tmp) s+=tolower(c);
    
    int cnt=0;
    for(char c:s) cnt+=!is_symbol(c);
    if(cnt<(int)ch[name].size()){      
      NO();
      continue;
    }
    
    if(name=="rabi"){
      YES();
      continue;      
    }

    int num=0;
    while(is_symbol(s.back())){
      num++;
      s.pop_back();      
    }
    if(num>3){
      NO();
      continue;
    }
    
    string t=s.substr(s.size()-ch[name].size());
    if(t==ch[name]) YES();
    else NO();
  }
  cout<<flush;
  return 0;
}
0