結果

問題 No.1170 Never Want to Walk
ユーザー hiro71687khiro71687k
提出日時 2023-02-27 05:06:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,614 bytes
コンパイル時間 4,211 ms
コンパイル使用メモリ 268,112 KB
実行使用メモリ 18,636 KB
最終ジャッジ日時 2023-10-12 17:14:17
合計ジャッジ時間 11,720 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 WA -
testcase_13 AC 3 ms
4,352 KB
testcase_14 WA -
testcase_15 AC 4 ms
4,352 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 3 ms
4,348 KB
testcase_19 WA -
testcase_20 AC 3 ms
4,352 KB
testcase_21 WA -
testcase_22 AC 3 ms
4,348 KB
testcase_23 AC 4 ms
4,348 KB
testcase_24 AC 3 ms
4,348 KB
testcase_25 AC 3 ms
4,348 KB
testcase_26 AC 4 ms
4,352 KB
testcase_27 AC 446 ms
18,620 KB
testcase_28 AC 435 ms
17,904 KB
testcase_29 AC 469 ms
18,636 KB
testcase_30 AC 445 ms
18,356 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 429 ms
17,812 KB
testcase_34 WA -
testcase_35 AC 419 ms
18,388 KB
testcase_36 AC 412 ms
17,808 KB
testcase_37 AC 420 ms
18,140 KB
testcase_38 AC 431 ms
18,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ll inf=10010010010010010;
ll mod=998244353;
int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    vector<ll>x(n);
    set<pair<ll,ll>>s;
    s.insert({inf,inf});
    for (ll i = 0; i < n; i++)
    {
        cin >> x[i];
        s.insert({x[i],i});
    }
    vector<ll>ans(n);
    while (1)
    {
        auto v=s.lower_bound({-1,1});
        pair<ll,ll>p=*(v);
        s.erase(p);
        if (p.first==inf)
        {
            break;
        }
        vector<pair<ll,ll>>memo;
        memo.push_back(p);
        for (ll i = 0; i < memo.size(); i++)
        {
            v=s.lower_bound({memo[i].first+a,-1});
            pair<ll,ll>q=*(v);
            if (q.first==inf)
            {
                continue;
            }
            while (a<=abs(q.first-memo[i].first)&&abs(q.first-memo[i].first)<=b)
            {
                s.erase(q);
                memo.push_back(q);
                v=s.lower_bound(q);
                q=*(v);
            }
            v=s.lower_bound({memo[i].first-b,-1});
            q=*(v);
            while (a<=abs(memo[i].first-q.first)&&abs(memo[i].first-q.first)<=b)
            {
                s.erase(q);
                memo.push_back(q);
                v=s.lower_bound(q);
                q=*(v);
            }
        }
        for (ll i = 0; i < memo.size(); i++)
        {
            ans[memo[i].second]=memo.size();
        }
    }
    for (ll i = 0; i < ans.size(); i++)
    {
        cout << ans[i] << endl;
    }
    
}
0