結果

問題 No.2771 Personal Space
ユーザー 沙耶花沙耶花
提出日時 2024-05-31 22:11:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 283 ms / 2,000 ms
コード長 1,156 bytes
コンパイル時間 4,694 ms
コンパイル使用メモリ 272,516 KB
実行使用メモリ 18,560 KB
最終ジャッジ日時 2024-05-31 22:11:43
合計ジャッジ時間 11,113 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 176 ms
18,560 KB
testcase_02 AC 177 ms
18,432 KB
testcase_03 AC 177 ms
18,432 KB
testcase_04 AC 174 ms
18,432 KB
testcase_05 AC 175 ms
18,432 KB
testcase_06 AC 177 ms
18,432 KB
testcase_07 AC 123 ms
6,944 KB
testcase_08 AC 283 ms
6,940 KB
testcase_09 AC 126 ms
6,944 KB
testcase_10 AC 143 ms
6,944 KB
testcase_11 AC 167 ms
13,184 KB
testcase_12 AC 167 ms
15,488 KB
testcase_13 AC 113 ms
6,940 KB
testcase_14 AC 128 ms
6,944 KB
testcase_15 AC 129 ms
6,940 KB
testcase_16 AC 129 ms
6,944 KB
testcase_17 AC 130 ms
6,940 KB
testcase_18 AC 127 ms
6,944 KB
testcase_19 AC 127 ms
6,944 KB
testcase_20 AC 164 ms
12,672 KB
testcase_21 AC 164 ms
12,032 KB
testcase_22 AC 154 ms
11,904 KB
testcase_23 AC 180 ms
17,280 KB
testcase_24 AC 155 ms
14,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0