結果
| 問題 | 
                            No.2771 Personal Space
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2024-06-01 16:59:47 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 269 ms / 2,000 ms | 
| コード長 | 1,098 bytes | 
| コンパイル時間 | 3,286 ms | 
| コンパイル使用メモリ | 257,112 KB | 
| 実行使用メモリ | 20,860 KB | 
| 最終ジャッジ日時 | 2024-12-22 03:33:04 | 
| 合計ジャッジ時間 | 11,351 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 24 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int MOD=998244353;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
void solve();
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int test_case;
  cin>>test_case;
  while (test_case--){
    solve();
  }
}
void solve(){
  int N,M;
  cin>>N>>M;
  M-=1;
  set<int>done;
  priority_queue<array<int,2>>pq;
  pq.push({0,-M});
  vector ans(N,0);
  int cnt=0;
  while(pq.size()){
    int v=-pq.top()[1],d=pq.top()[0];
    pq.pop();
    int l=-N,r=N*2;
    if(done.contains(v))continue;
    auto it0=done.upper_bound(v);
    if(it0!=done.end())r=*it0;
    auto it1=done.lower_bound(v);
    if(it1!=done.begin()){
      it1--;
      l=*it1;
    }
    if(d>min(v-l,r-v))continue;
    ans[v]=++cnt;
    done.insert(v);
    if(l==-N){
      pq.push({v,0});
    }else{
      pq.push({(v-l)/2,-(l+(v-l)/2)});
    }
    if(r==N*2){
      pq.push({N-1-v,-(N-1)});
    }else{
      pq.push({(r-v)/2,-(v+(r-v)/2)});
    }
  }
  rep(i,N){
    if(i)cout<<' ';
    cout<<ans[i];
  }
  cout<<'\n';
}