結果

問題 No.1950 片道きゃっちぼーる
ユーザー otoshigootoshigo
提出日時 2022-05-20 23:26:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,542 bytes
コンパイル時間 5,328 ms
コンパイル使用メモリ 282,240 KB
実行使用メモリ 35,628 KB
最終ジャッジ日時 2023-10-20 14:22:26
合計ジャッジ時間 12,392 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,700 KB
testcase_01 AC 2 ms
5,700 KB
testcase_02 AC 2 ms
5,700 KB
testcase_03 AC 219 ms
32,988 KB
testcase_04 AC 227 ms
32,988 KB
testcase_05 AC 2 ms
5,700 KB
testcase_06 AC 242 ms
32,988 KB
testcase_07 AC 211 ms
35,628 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 251 ms
32,988 KB
testcase_12 AC 218 ms
32,988 KB
testcase_13 AC 241 ms
31,208 KB
testcase_14 AC 256 ms
31,208 KB
testcase_15 WA -
testcase_16 AC 249 ms
32,196 KB
testcase_17 WA -
testcase_18 AC 232 ms
32,460 KB
testcase_19 WA -
testcase_20 AC 221 ms
35,628 KB
testcase_21 AC 258 ms
32,988 KB
testcase_22 AC 260 ms
32,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using mint = atcoder::modint998244353;
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,a,b) for (int i = a; i < b; i++)
#define rrep2(i,a,b) for (int i = a-1; i >= b; i--)
#define rep3(i,a,b,c) for (int i = a; i < b; i+=c)
#define rrep3(i,a,b,c) for (int i = a-1; i >= b; i-=c)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}
#define int long long

int n,X[200010],A[200010];
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    atcoder::dsu uf(n);
    map<int,int>mp;
    rep(i,n){
        cin>>X[i];
        mp[X[i]]=i;
    }
    vector<pair<int,int>>vp;
    rep(i,n){
        cin>>A[i];
        vp.push_back(make_pair(A[i]+X[i],i));
        if(mp.count(X[i]-A[i]))uf.merge(i,mp[X[i]-A[i]]);
        if(mp.count(X[i]+A[i]))uf.merge(i,mp[X[i]+A[i]]);
    }
    sort(rall(vp));
    vector<bool>flag(n);
    vector<vector<int>>vv(n);
    rep(i,n){
        vv[uf.leader(i)].push_back(i);
    }
    vector<int>Ans(n);
    for(auto[c,x]:vp){
        int l=uf.leader(x);
        if(flag[l])continue;
        flag[l]=true;
        vector<int>g=vv[l];
        for(auto i:g){
            Ans[i]=A[x]+(X[x]-X[i]);
        }
    }
    rep(i,n)cout<<Ans[i]<<"\n";
}
0