結果
| 問題 | No.3627 Share the Median |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-14 23:05:35 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,672 bytes |
| 記録 | |
| コンパイル時間 | 3,038 ms |
| コンパイル使用メモリ | 283,972 KB |
| 実行使用メモリ | 9,540 KB |
| 平均クエリ数 | 9.45 |
| 最終ジャッジ日時 | 2026-08-14 23:05:46 |
| 合計ジャッジ時間 | 6,668 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| Sample | 0 % | |
| Easy | 20 % | AC * 8 WA * 8 |
| Hard | 80 % | AC * 15 WA * 9 |
| 合計 | 3 * 0% = 0 点 |
ソースコード
#include <iostream>
#include <ranges>
#include <algorithm>
#include <vector>
using namespace std;
using ll=long long;
#include <atcoder/all>
using mint=atcoder::modint998244353;
ostream& operator<<(ostream& os,mint& x){
os<<x.val();
return os;
}
istream& operator>>(istream& is,mint& x){
int t;
is>>t;
x=t;
return is;
}
template <typename S,typename T>
ostream& operator<<(ostream& os,const pair<S,T>& p);
template <typename S,typename T>
istream& operator>>(istream& is,pair<S,T>& p);
template <typename T,size_t n>
ostream& operator<<(ostream& os,const array<T,n>& arr);
template <typename T,size_t n>
istream& operator>>(istream& is,array<T,n>& arr);
template <typename T>
ostream& operator<<(ostream& os,const vector<T>& vec);
template <typename T>
istream& operator>>(istream& is,vector<T>& vec);
template <typename S,typename T>
ostream& operator<<(ostream& os,pair<S,T>& p){
os<<p.first<<" "<<p.second;
return os;
}
template <typename S,typename T>
istream& operator>>(istream& is,pair<S,T>& p){
is>>p.first>>p.second;
return is;
}
template <typename T,size_t n>
ostream& operator<<(ostream& os,array<T,n>& arr){
for(int i=0;i<n;i++)os<<arr[i]<<(i+1==n?"":" ");
return os;
}
template <typename T,size_t n>
istream& operator>>(istream& is,array<T,n>& arr){
for(int i=0;i<n;i++)is>>arr[i];
return is;
}
template <typename T>
ostream& operator<<(ostream& os,vector<T>& vec){
for(int i=0;i<vec.size();i++)os<<vec[i]<<(i+1==vec.size()?"":" ");
return os;
}
template <typename T>
istream& operator>>(istream& is,vector<T>& vec){
for(int i=0;i<vec.size();i++)is>>vec[i];
return is;
}
#include <map>
map<int,ll> mp;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
string player;
cin>>player;
int q;
cin>>q;
int n,m;
cin>>n>>m;
if(player=="Bob"){
swap(n,m);
}
vector<array<ll,2>> x(n);
for(int i=0;i<n;i++){
cin>>x[i][0];
x[i][1]=i;
}
ranges::sort(x);
int l=-1,r=n;
int a=-1,b=m;
while(l+1<r||a+1<b){
if(q==0){
ll t=1;
for(ll i=1;i<=1e15;i++){
t*=i;
}
cout<<t<<endl;
return 0;
}
q--;
ll h,c;
if((r-l>b-a)||(r-l==b-a&&n%2==1)){
h=(l+r)/2;
c=(n+m)/2-h;
}else{
c=(a+b)/2;
h=(n+m)/2-c;
}
/*
cout<<l<<" "<<r<<" "<<h<<endl;
cout<<a<<" "<<b<<" "<<c<<endl;
//*/
cout<<"share"<<" "<<x[h][1]+1<<endl;
ll v;
cin>>v;
if((r-l>b-a)||(r-l==b-a&&n%2==1)){
if(v<=x[h][0]){
r=h;
a=c;
}else{
l=h;
b=c;
}
}else{
if(x[h][0]<=v){
b=c;
l=h;
}else{
a=c;
r=h;
}
}
mp[c]=v;
}
int cnt=a+1;
for(int i=0;i<n;i++)if(x[i][0]<=mp[a])cnt++;
if(2*cnt==n+m+1)cout<<"answer "<<mp[a]<<endl;
else cout<<"answer "<<x[l][0]<<endl;
}