結果

問題 No.1170 Never Want to Walk
ユーザー warabi0906warabi0906
提出日時 2023-02-06 16:28:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 382 ms / 2,000 ms
コード長 1,940 bytes
コンパイル時間 3,701 ms
コンパイル使用メモリ 230,092 KB
実行使用メモリ 7,112 KB
最終ジャッジ日時 2023-09-18 03:37:51
合計ジャッジ時間 10,611 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 366 ms
6,732 KB
testcase_28 AC 365 ms
6,828 KB
testcase_29 AC 374 ms
7,080 KB
testcase_30 AC 382 ms
6,836 KB
testcase_31 AC 370 ms
6,828 KB
testcase_32 AC 356 ms
6,720 KB
testcase_33 AC 370 ms
7,036 KB
testcase_34 AC 370 ms
7,000 KB
testcase_35 AC 355 ms
6,880 KB
testcase_36 AC 356 ms
6,788 KB
testcase_37 AC 356 ms
6,848 KB
testcase_38 AC 362 ms
7,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include "atcoder/all"
#define debug cout << "OK" << endl;
template<typename T>
inline bool chmax(T& a, const T b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
inline bool chmin(T& a, const T b) { if (a > b) { a = b; return true; } return false; }
inline int Code(char c) {
	if ('A' <= c and c <= 'Z')return (int)(c - 'A');
	if ('a' <= c and c <= 'z')return (int)(c - 'a');
	if ('0' <= c and c <= '9')return (int)(c - '0');
	assert(false);
}
using namespace std;
using namespace atcoder;
#define int long long
constexpr int MOD = 998244353;
constexpr int INF = (1LL << 62);
using minit = modint998244353;

template<typename T>
ostream& operator << (ostream& st, const vector<T> &v) {
	for (const T value : v) {
		st << value << " ";
	}
	return st;
}
template<typename T>
istream& operator >> (istream& st, vector<T>& v) {
	for (T &value : v) {
		st >> value;
	}
	return st;
}

//

//

void solve() {
	int N, A, B;
	cin >> N >> A >> B;
	vector<int> x(N);
	cin >> x;
	dsu d(N);
	vector<int> imos(N , 0);
	for (int i = 0; i < N; i++) {
		auto l = lower_bound(x.begin(), x.end(), x[i] + A);
		auto r = upper_bound(x.begin(), x.end(), x[i] + B);
		if (l == r)goto next;
		else r--;
		imos[distance(x.begin(), l)]++, imos[distance(x.begin(), r)]--, d.merge(i, distance(x.begin(), l));
	next:;
		l = lower_bound(x.begin(), x.end(), x[i] - B);
		r = upper_bound(x.begin(), x.end(), x[i] - A);
		if (l == r)continue;
		else r--;
		imos[distance(x.begin(), l)]++, imos[distance(x.begin(), r)]--, d.merge(i, distance(x.begin(), l));
	}
	for (int i = 0; i < N - 1; i++)imos[i + 1] += imos[i];
	for (int i = 0; i < N - 1; i++)if (imos[i])d.merge(i, i + 1);
	for (int i = 0; i < N; i++) {
		cout << d.size(i) << endl;
	}
}
signed main() {
	int T = 1;
	// cin >> T;
	for (int i = 0; i < T; i++)
		solve();
	return 0;
}

/*
* わらびのコードこーどすぺーす
 (σ・∀・)σゲッツ!!
*/
0