結果

問題 No.2673 A present from B
ユーザー t9unkubjt9unkubj
提出日時 2024-03-15 22:20:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,149 bytes
コンパイル時間 2,428 ms
コンパイル使用メモリ 209,244 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-03-15 22:20:19
合計ジャッジ時間 3,565 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,548 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 3 ms
6,548 KB
testcase_11 AC 2 ms
6,548 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
6,548 KB
testcase_23 AC 2 ms
6,548 KB
testcase_24 AC 2 ms
6,548 KB
testcase_25 AC 2 ms
6,548 KB
testcase_26 AC 2 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 * author:	t9unkubj
 * created:	2024-03-15 
 */

#include<bits/stdc++.h>

#ifdef t9unkubj
#define _GLIBCXX_DEBUG
#define dbg(x) cout<<__LINE__<<" "<<#x<<":="<<x<<endl;
#else 
#define dbg(x) t9unkubj
#endif

using namespace std;

//#include<atcoder/all>
//using namespace atcoder;
int main(){
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n,m;
	cin>>n>>m;
	vector<int>a(m);
	for(int i=0;i<m;i++)cin>>a[i],a[i]--;
	vector<vector<int>>togo(m+1,vector<int>(n));
	vector<vector<int>>inv(m+1,vector<int>(n));
	vector<vector<int>>origin(m+1,vector<int>(n));
	vector<vector<int>>inv2=origin;
	iota(origin[0].begin(),origin[0].end(),0);
	for(int i=0;i<m;i++){
		origin[i+1]=origin[i];
		swap(origin[i+1][a[i]],origin[i+1][a[i]+1]);
	}
	for(int i=0;i<=m;i++)for(int j=0;j<n;j++)inv2[i][origin[i][j]]=j;
	iota(togo[m].begin(),togo[m].end(),0);
	for(int i=m-1;i>=0;i--){
		togo[i]=togo[i+1];
		swap(togo[i][a[i]],togo[i][a[i]+1]);
	}
	for(int i=0;i<=m;i++)for(int j=0;j<n;j++)inv[i][togo[i][j]]=j;
	for(int i=1;i<n;i++){
		int ans=1e9;
		for(int j=0;j<=m;j++){
			ans=min(ans,abs(inv[j][0]-inv2[j][i]));
		}
		cout<<ans<<" ";
	}
	cout<<endl;
}
0