結果

問題 No.380 悪の台本
ユーザー not_522not_522
提出日時 2016-12-16 02:21:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 153 ms / 1,000 ms
コード長 1,344 bytes
コンパイル時間 2,058 ms
コンパイル使用メモリ 178,696 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 14:52:48
合計ジャッジ時間 2,913 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  map<string, string> m;
  m["digi"] = "nyo";
  m["petit"] = "nyu";
  m["gema"] = "gema";
  m["piyo"] = "pyo";
  string line, name;
  while (getline(cin, line)) {
    stringstream ss(line);
    ss >> name;
    if (line == name || !isalpha(line[0])) {
      cout << "WRONG!" << endl;
      continue;
    }
    line = line.substr(name.size() + 1);
    if (name == "rabi") {
      if (find_if(line.begin(), line.end(), [](char c){return isalnum(c);}) != line.end()) {
        cout << "CORRECT (maybe)" << endl;
      } else {
        cout << "WRONG!" << endl;
      }
    } else {
      if (!m.count(name)) {
        cout << "WRONG!" << endl;
        continue;
      }
      for (char& c : line) c = tolower(c);
      reverse(line.begin(), line.end());
      int cnt = find_if(line.begin(), line.end(), [](char c){return isalnum(c);}) - line.begin();
      reverse(line.begin(), line.end());
      if (cnt <= 3 && cnt + m[name].size() <= line.size() && m[name] == line.substr(line.size() - cnt - m[name].size(), m[name].size())) {
        cout << "CORRECT (maybe)" << endl;
      } else {
        cout << "WRONG!" << endl;
      }
    }
  }
}
0