結果
問題 |
No.380 悪の台本
|
ユーザー |
![]() |
提出日時 | 2025-04-18 01:01:19 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,712 bytes |
コンパイル時間 | 3,097 ms |
コンパイル使用メモリ | 283,296 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-04-18 01:01:23 |
合計ジャッジ時間 | 3,951 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 6 WA * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long #define NO { cout << "WRONG!\n"; continue; } #define YES { cout << "CORRECT (maybe)\n"; continue; } bool is_symbol(char c) { return !isdigit(c) && !isalpha(c); } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); // mapping from character name to lowercase ?root? suffix map<string,string> mp = { {"digi", "nyo"}, {"petit", "nyu"}, {"gema", "gema"}, {"piyo", "pyo"} }; string line; while (getline(cin, line) && !line.empty()) { // split on the *first* space auto pos = line.find(' '); if (pos == string::npos) NO string name = line.substr(0, pos); string s = line.substr(pos + 1); if (name == "rabi") { // must contain at least one non-symbol bool ok = false; for (char c : s) { if (!is_symbol(c)) { ok = true; break; } } if (ok) YES else NO } else { // peel off up to 3 trailing symbols int cnt = 0; while (!s.empty() && is_symbol(s.back())) { cnt++; s.pop_back(); } if (cnt > 3) NO auto it = mp.find(name); if (it == mp.end()) NO // case?insensitive compare for the root suffix string root = it->second; for (char &c : s) c = tolower(c); if (s.size() >= root.size() && s.substr(s.size() - root.size()) == root) { YES } else { NO } } } return 0; }