結果
| 問題 | No.1170 Never Want to Walk |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-10-31 00:15:11 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 17 ms / 2,000 ms |
| + 224µs | |
| コード長 | 2,198 bytes |
| 記録 | |
| コンパイル時間 | 602 ms |
| コンパイル使用メモリ | 101,996 KB |
| 実行使用メモリ | 9,928 KB |
| 最終ジャッジ日時 | 2026-10-31 00:15:17 |
| 合計ジャッジ時間 | 4,827 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 38 |
ソースコード
#include <cstdio>
#include <vector>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
using ll = long long;
// 整数を 1 つ読む。cp-library の `read_i` と同じく、getchar_unlocked で空白を読み飛ばし、
// 符号と数字を読んで、数字の次の 1 文字を入力に戻す。
static inline ll fast_read() {
int c = getchar_unlocked();
while (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\v' || c == '\f') {
c = getchar_unlocked();
}
bool negative = false;
if (c == '-' || c == '+') {
negative = c == '-';
c = getchar_unlocked();
}
unsigned long long value = 0;
while ('0' <= c && c <= '9') {
value = value * 10 + (unsigned long long)(c - '0');
c = getchar_unlocked();
}
if (c != EOF) {
ungetc(c, stdin);
}
return negative ? -(ll)value : (ll)value;
}
// 整数を 1 つと改行を、putchar_unlocked で書く。
static inline void fast_write(ll v) {
char buf[24];
int n = 0;
unsigned long long u = v < 0 ? 0ULL - (unsigned long long)v : (unsigned long long)v;
if (v < 0) {
putchar_unlocked('-');
}
do {
buf[n++] = (char)('0' + u % 10);
u /= 10;
} while (u);
while (n) {
putchar_unlocked(buf[--n]);
}
putchar_unlocked('\n');
}
int main() {
ll n, a, b;
n = fast_read();
a = fast_read();
b = fast_read();
vector<ll> xs(n);
for (auto &x : xs) {
x = fast_read();
}
dsu uf(n);
ll begin = 0, end = 0;
for (ll i = 0; i < n; i++) {
ll begin1 = begin;
while (begin1 < n && xs[i] + a > xs[begin1]) {
begin1++;
}
ll end1 = end;
while (end1 < n && xs[i] + b >= xs[end1]) {
end1++;
}
if (i == 0 || begin1 >= end) {
for (ll j = begin1; j < end1; j++) {
uf.merge(i, j);
}
} else {
for (ll j = end - 1; j < end1; j++) {
uf.merge(i, j);
}
}
begin = begin1;
end = end1;
}
for (ll i = 0; i < n; i++) {
fast_write(uf.size(i));
}
}