結果
| 問題 |
No.2771 Personal Space
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2024-05-31 22:11:29 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 292 ms / 2,000 ms |
| コード長 | 1,156 bytes |
| コンパイル時間 | 4,317 ms |
| コンパイル使用メモリ | 258,412 KB |
| 最終ジャッジ日時 | 2025-02-21 17:59:43 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 24 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
int main(){
int _t;
cin>>_t;
rep(_,_t){
int N,M;
cin>>N>>M;
M--;
vector<int> ans(N,-1);
ans[M] = 0;
set<pair<int,int>> s;
set<int> pos;
pos.insert(M);
if(M!=0)s.emplace(-(M),0);
if(M!=N-1)s.emplace(-(N-1-(M)),N-1);
for(int i=1;i<N;i++){
auto x = *s.begin();
s.erase(s.begin());
ans[x.second] = i;
//cout<<x.first<<' '<<x.second<<endl;
{
auto it = pos.lower_bound(x.second);
if(it==pos.end()){
}
else{
int d = (*it) - x.second;
d /= 2;
if(d!=0){
s.emplace(-d,x.second+d);
}
}
}
{
auto it = pos.lower_bound(x.second);
if(it==pos.begin()){
}
else{
it--;
int d = x.second - (*it);
d /= 2;
if(d!=0){
s.emplace(-d,(*it)+d);
}
}
}
pos.insert(x.second);
}
rep(i,N){
if(i!=0)cout<<' ';
cout<<ans[i]+1;
}
cout<<endl;
}
return 0;
}
沙耶花