結果
問題 | No.2771 Personal Space |
ユーザー | nonon |
提出日時 | 2024-05-31 22:52:43 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 665 ms / 2,000 ms |
コード長 | 1,054 bytes |
コンパイル時間 | 2,333 ms |
コンパイル使用メモリ | 208,516 KB |
実行使用メモリ | 13,688 KB |
最終ジャッジ日時 | 2024-05-31 22:52:59 |
合計ジャッジ時間 | 16,369 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 661 ms
13,664 KB |
testcase_02 | AC | 665 ms
13,624 KB |
testcase_03 | AC | 659 ms
13,616 KB |
testcase_04 | AC | 663 ms
13,688 KB |
testcase_05 | AC | 661 ms
13,628 KB |
testcase_06 | AC | 635 ms
13,656 KB |
testcase_07 | AC | 246 ms
6,940 KB |
testcase_08 | AC | 57 ms
6,940 KB |
testcase_09 | AC | 261 ms
6,944 KB |
testcase_10 | AC | 504 ms
6,944 KB |
testcase_11 | AC | 598 ms
8,664 KB |
testcase_12 | AC | 554 ms
9,056 KB |
testcase_13 | AC | 141 ms
6,940 KB |
testcase_14 | AC | 275 ms
6,940 KB |
testcase_15 | AC | 363 ms
6,940 KB |
testcase_16 | AC | 363 ms
6,940 KB |
testcase_17 | AC | 435 ms
6,940 KB |
testcase_18 | AC | 248 ms
6,944 KB |
testcase_19 | AC | 216 ms
6,940 KB |
testcase_20 | AC | 597 ms
8,716 KB |
testcase_21 | AC | 571 ms
8,556 KB |
testcase_22 | AC | 601 ms
8,460 KB |
testcase_23 | AC | 617 ms
13,440 KB |
testcase_24 | AC | 609 ms
9,040 KB |
ソースコード
#include<bits/stdc++.h> #include<atcoder/segtree> using namespace std; int N,M; pair<int,int>op(pair<int,int>p,pair<int,int>q) { return p.first==q.first?p.second<q.second?p:q:p.first>q.first?p:q; } pair<int,int>e(){return make_pair(-1,N);} void solve() { cin>>N>>M; M--; atcoder::segtree<pair<int,int>,op,e>seg(N); for(int i=0;i<N;i++)seg.set(i,make_pair(1<<30,i)); vector<int>ans(N,-1); ans[M]=0; auto update=[&](int p)->void { int d=0; for(int i=p;i<N&&seg.get(i).first>d;i++) { seg.set(i,make_pair(d,i)); d++; } d=1; for(int i=p-1;i>=0&&seg.get(i).first>d;i--) { seg.set(i,make_pair(d,i)); d++; } }; update(M); for(int i=1;i<N;i++) { int j=seg.prod(0,N).second; update(j); ans[j]=i; } for(int i=0;i<N;i++)cout<<ans[i]+1<<" \n"[i+1==N]; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin>>T; while(T--){solve();} }