結果

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

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string player;
  cin >> player;
  int side = player == "Alice" ? 0 : 1;
  int q, n, m;
  cin >> q >> n >> m;
  vector<P> a(n), b(m);
  if (side == 0) {
    rep(i, n) cin >> a[i].first, a[i].second = i;
  } else {
    rep(i, m) cin >> b[i].first, b[i].second = i;
  }
  sort(all(a));
  sort(all(b));
  if (n < m) swap(a, b), swap(n, m), side ^= 1;
  int mid = (n + m - 1) / 2;
  int l = mid - m, r = mid + 1;
  int ans = 0;
  while (r - l > 1) {
    int c = (l + r) / 2;
    int d = mid - c;
    int va = a[c].first, vb = b[d].first;
    if (side == 0) cout << "share " << a[c].second + 1 << endl;
    else cout << "share " << b[d].second + 1 << endl;
    int res;
    cin >> res;
    (side == 0 ? vb : va) = res;
    chmax(ans, min(va, vb));
    (va >= vb ? r : l) = c;
  }
  if (l == mid - m) {
    ans = a[mid - m].first;
  }
  cout << "answer " << ans << endl;
}
0