結果

問題 No.1170 Never Want to Walk
コンテスト
ユーザー 👑 tttmmmyyyy
提出日時 2026-10-31 00:13:08
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 38 ms / 2,000 ms
+ 82µs
コード長 956 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 576 ms
コンパイル使用メモリ 99,060 KB
実行使用メモリ 9,848 KB
最終ジャッジ日時 2026-10-31 00:13:15
合計ジャッジ時間 6,843 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <cstdio>
#include <vector>
#include <atcoder/dsu>

using namespace std;
using namespace atcoder;
using ll = long long;

int main() {
    ll n, a, b;
    scanf("%lld %lld %lld", &n, &a, &b);
    vector<ll> xs(n);
    for (auto &x : xs) {
        scanf("%lld", &x);
    }
    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++) {
        printf("%d\n", uf.size(i));
    }
}
0