結果

問題 No.380 悪の台本
ユーザー どららどらら
提出日時 2016-06-18 00:27:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 138 ms / 1,000 ms
コード長 3,461 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 80,392 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-06 19:47:08
合計ジャッジ時間 1,550 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 6 ms
4,376 KB
testcase_05 AC 16 ms
4,380 KB
testcase_06 AC 16 ms
4,376 KB
testcase_07 AC 138 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 8 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0