結果

問題 No.1170 Never Want to Walk
ユーザー fastmathfastmath
提出日時 2020-08-16 22:16:17
言語 C++17(clang)
(14.0.0 + boost 1.83.0)
結果
AC  
実行時間 275 ms / 2,000 ms
コード長 1,427 bytes
コンパイル時間 2,233 ms
コンパイル使用メモリ 136,880 KB
実行使用メモリ 41,244 KB
最終ジャッジ日時 2023-08-01 19:32:46
合計ジャッジ時間 7,621 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
5,476 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
5,516 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,508 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 2 ms
5,592 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 3 ms
5,608 KB
testcase_21 AC 2 ms
5,608 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 3 ms
5,664 KB
testcase_26 AC 3 ms
5,240 KB
testcase_27 AC 260 ms
29,176 KB
testcase_28 AC 260 ms
28,120 KB
testcase_29 AC 275 ms
27,880 KB
testcase_30 AC 263 ms
29,024 KB
testcase_31 AC 257 ms
28,320 KB
testcase_32 AC 246 ms
38,892 KB
testcase_33 AC 244 ms
38,732 KB
testcase_34 AC 263 ms
40,036 KB
testcase_35 AC 250 ms
40,456 KB
testcase_36 AC 246 ms
39,004 KB
testcase_37 AC 253 ms
39,208 KB
testcase_38 AC 264 ms
41,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
const int N = 2e5+7;
map <int, int> num;
set <int> nu;
int comp[N], cnt[N];
int n, l, r;
void dfs(int x, int c) {
    comp[num[x]] = c;
    cnt[c]++;
    nu.erase(x);

    while (1) {
        auto t = nu.lower_bound(x - r);
        if (t != nu.end() && *t <= x - l) {
            dfs(*t, c);
        }   
        else {
            break;
        }   
    }   

    while (1) {
        auto t = nu.lower_bound(x + l);
        if (t != nu.end() && *t <= x + r) {
            dfs(*t, c);
        }   
        else {
            break;
        }   
    }   
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n >> l >> r;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        nu.insert(a[i]);
        num[a[i]] = i;
    }       
    int c = 0;
    while (nu.size()) {
        dfs(*nu.begin(), c++);
    }   
    for (int i = 0; i < n; ++i) {
        cout << cnt[comp[i]] << endl;
    }                               
}
0