結果

問題 No.2673 A present from B
ユーザー AerenAeren
提出日時 2024-03-15 21:43:16
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 931 bytes
コンパイル時間 3,515 ms
コンパイル使用メモリ 251,544 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-15 21:43:26
合計ジャッジ時間 4,143 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,676 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 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,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
#if __cplusplus >= 202002L
using namespace numbers;
#endif



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> gift(m + 1, vector<int>(n));
	vector<vector<int>> pos(m + 1, vector<int>(n));
	iota(gift[0].begin(), gift[0].end(), 0);
	iota(pos[0].begin(), pos[0].end(), 0);
	for(auto i = 0; i < m; ++ i){
		gift[i + 1] = gift[i];
		int x;
		cin >> x, -- x;
		swap(gift[i + 1][x], gift[i + 1][x + 1]);
		for(auto j = 0; j < n; ++ j){
			pos[i + 1][gift[i + 1][j]] = j;
		}
	}
	int obj = gift[m][0];
	for(auto x = 1; x < n; ++ x){
		int res = numeric_limits<int>::max();
		for(auto step = 0; step <= m; ++ step){
			res = min(res, abs(pos[step][obj] - pos[step][x]));
		}
		cout << res << " ";
	}
	cout << "\n";
	return 0;
}

/*

*/
0