結果

問題 No.3246 80% Accuracy Calculator
ユーザー AngrySadEight
提出日時 2025-07-26 18:11:38
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,689 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 82,948 KB
実行使用メモリ 25,996 KB
平均クエリ数 61.00
最終ジャッジ日時 2025-07-27 02:49:40
合計ジャッジ時間 4,399 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
using ll = long long;

ll get_most(char reg, ll times) {
    map<ll, ll> mp;

    for (ll i = 0; i < times; i++) {
        cout << "? " << reg << endl;
        ll val;
        cin >> val;
        if (val == -1) {
            return -1;
        }
        mp[val]++;
    }
    ll max_times = 0;
    ll max_val = -1;
    for (auto it = mp.begin(); it != mp.end(); it++) {
        if (max_times < it->second) {
            max_times = it->second;
            max_val = it->first;
        }
    }
    return max_val;
}

int main() {
    ll x = get_most('A', 30);
    ll y = get_most('B', 30);

    ll now = 2;
    for (ll i = 0; i < y; i++) {
        if (now == 2) {
            while (true) {
                cout << "+ A C B" << endl;
                ll z;
                cin >> z;
                if (z == 0) {
                    return 0;
                }
                ll val = get_most('B', 7);
                if (val == -1) {
                    return 0;
                }
                if (val == i * x + x) {
                    break;
                }
            }
            now = 1;
        } else {
            while (true) {
                cout << "+ A B C" << endl;
                ll z;
                cin >> z;
                if (z == 0) {
                    return 0;
                }
                ll val = get_most('C', 7);
                if (val == i * x + x) {
                    break;
                }
            }
            now = 2;
        }
    }
    if (now == 1) {
        cout << "! B" << endl;
    } else {
        cout << "! C" << endl;
    }
}
0