結果

問題 No.3627 Share the Median
コンテスト
ユーザー GOTKAKO
提出日時 2026-08-15 02:07:38
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 1,284 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,269 ms
コンパイル使用メモリ 219,844 KB
実行使用メモリ 9,548 KB
平均クエリ数 2.90
最終ジャッジ日時 2026-08-15 02:07:52
合計ジャッジ時間 7,547 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
Sample 0 %
Easy 20 % AC * 7 RE * 9
Hard 80 % AC * 7 RE * 17
合計 3 * 0% = 0 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s; cin >> s;
    int Q; cin >> Q;
    int N,M; cin >> N >> M;
    if(s == "Bob") swap(N,M);
    vector<pair<int,int>> X(N);
    int idx = 0;
    for(auto &[x,p] : X) cin >> x,p = idx++;
    sort(X.begin(),X.end());

    auto share = [&](int pos) -> int {
        cout << "share " << pos+1 << endl;
        int ret; cin >> ret;
        if(ret == -1) assert(false);
        return ret;
    };
    auto answer = [&](int x) -> void {cout << "answer " << x << endl; exit(0);};

    int low = share(X.at(0).second),high = share(X.back().second);
    if(low == high && X.at(0).first == X.back().first){
        if(N > M) answer(X.at(0).first);
        else answer(low);
    }
    else if(low == high){
        for(int i=0; i<M; i++) X.push_back({low,-1});
        sort(X.begin(),X.end());
        auto [x,pos] = X.at((N+M)/2);
        if(pos == -1) share(X.at(0).second),share(X.back().second);
        else share(pos),share(pos); 
        answer(x);
    }
    else if(X.at(0).first == X.back().first){
        auto v1 = share(0),v2 = share(0);
        if(v1 == v2) answer(v1);
        else answer(X.at(0).first);
    }
    else{
        assert(false);
    }
}
0