結果
| 問題 | No.3627 Share the Median |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-15 02:05:50 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,265 bytes |
| 記録 | |
| コンパイル時間 | 1,452 ms |
| コンパイル使用メモリ | 220,100 KB |
| 実行使用メモリ | 9,452 KB |
| 平均クエリ数 | 2.75 |
| 最終ジャッジ日時 | 2026-08-15 02:06:03 |
| 合計ジャッジ時間 | 7,801 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| Sample | 0 % | |
| Easy | 20 % | AC * 2 WA * 5 RE * 9 |
| Hard | 80 % | AC * 1 WA * 6 RE * 17 |
| 合計 | 3 * 0% = 0 点 |
ソースコード
#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);
}
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);
}
}