結果

問題 No.380 悪の台本
ユーザー alpha_virginisalpha_virginis
提出日時 2016-06-17 23:29:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 131 ms / 1,000 ms
コード長 1,399 bytes
コンパイル時間 1,194 ms
コンパイル使用メモリ 146,932 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-06 19:39:14
合計ジャッジ時間 2,037 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

bool check(std::string& str, std::string t, int remain) {
  if( str.size() < t.size() ) return false;
  bool b = true;
  for(int i = 0; i < (int)t.size(); ++i) {
    if( toupper(str[str.size()-t.size()+i]) != toupper(t[i]) ) {
      b = false;
      break;
    }
  }
  if( b ) return true;
  if( remain <= 0 ) return false;
  char c = str[str.size()-1];
  if( isalnum(c) ) return false;
  str.pop_back();
  return check(str, t, remain - 1);
}

int main() {
  for(;;) {
    std::string name, str, temp;
    if( not std::getline(std::cin, temp) ) break;
    for(int i = 0; i < (int)temp.size(); ++i) {
      if( temp[i] != ' ' ) {
        name += temp[i];
      }
      else {
        for(int j = i; j < (int)temp.size(); ++j) {
          str += temp[j];
        }
        goto label_1;
      }
    }
  label_1:;
    //if( not ( std::cin >> name ) ) break;
    //std::getline(std::cin, str);
    bool res = false;
    if( name == "digi" )  res = check(str, "nyo", 3);
    if( name == "petit" ) res = check(str, "nyu", 3);
    if( name == "gema" )  res = check(str, "gema", 3);
    if( name == "piyo" )  res = check(str, "pyo", 3);
    if( name == "rabi" ) {
      bool b = false;
      for(int i = 0; i < (int)str.size(); ++i) {
        if( isalnum(str[i]) ) b = true;
      }
      res = b;
    }
    printf("%s\n", res ? "CORRECT (maybe)" : "WRONG!");
  }
  
  return 0;
}
0