結果

問題 No.1170 Never Want to Walk
ユーザー auauaauaua
提出日時 2020-08-14 23:18:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,683 bytes
コンパイル時間 1,773 ms
コンパイル使用メモリ 167,944 KB
実行使用メモリ 32,920 KB
最終ジャッジ日時 2024-04-18 23:10:17
合計ジャッジ時間 7,191 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
12,032 KB
testcase_01 AC 4 ms
6,528 KB
testcase_02 AC 4 ms
6,528 KB
testcase_03 AC 4 ms
6,400 KB
testcase_04 AC 4 ms
6,656 KB
testcase_05 AC 4 ms
6,528 KB
testcase_06 AC 4 ms
6,656 KB
testcase_07 AC 4 ms
6,528 KB
testcase_08 AC 4 ms
6,528 KB
testcase_09 AC 4 ms
6,528 KB
testcase_10 AC 4 ms
6,528 KB
testcase_11 AC 4 ms
6,656 KB
testcase_12 AC 4 ms
6,400 KB
testcase_13 AC 4 ms
6,528 KB
testcase_14 AC 5 ms
6,656 KB
testcase_15 AC 5 ms
6,528 KB
testcase_16 AC 5 ms
6,528 KB
testcase_17 AC 5 ms
6,656 KB
testcase_18 AC 5 ms
6,656 KB
testcase_19 AC 5 ms
6,656 KB
testcase_20 AC 5 ms
6,528 KB
testcase_21 AC 5 ms
6,400 KB
testcase_22 AC 12 ms
6,656 KB
testcase_23 AC 7 ms
6,656 KB
testcase_24 AC 11 ms
6,400 KB
testcase_25 AC 12 ms
6,400 KB
testcase_26 AC 9 ms
6,400 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=2e5+3;
const int MAX=1000010;

int siz[200010];
int par[200010];
int depth[200010];
void init(int n){
  for(int i=0;i<=n;i++){
      par[i]=i;
      depth[i]=0;
  }
  rep(i,n+1){
      siz[i]=1;
  }
}
int root(int x){
  return par[x]==x?x:par[x]=root(par[x]);
}
bool same(int x,int y){
  return root(x)==root(y);
}
void unite(int x,int y){
  x=root(x);
  y=root(y);
  ll sx=siz[x];
  ll sy=siz[y];
  if(x==y)return;
  if(depth[x]<depth[y]){
      par[x]=y;
  }else{
      par[y]=x;
      if(depth[x]==depth[y])depth[x]++;
  }
  siz[root(x)]=sx+sy;
}
vector<ll>x(200010,inf);
vector<ll>used(200010);
ll a,b;
void dfs(ll i){
    if(used[i])return;
    used[i]=1;
    ll l=lower_bound(all(x),x[i]+a)-x.begin();
    ll r=upper_bound(all(x),x[i]+b)-x.begin();
    REP(j,l,r){
        dfs(j);
        unite(i,j);
    }
    l=lower_bound(all(x),x[i]-b)-x.begin();
    r=upper_bound(all(x),x[i]-a)-x.begin();
    REP(j,l,r){
        dfs(j);
        unite(i,j);
    }
}
signed main(){
    ll n;cin>>n>>a>>b;
    init(n);
    rep(i,n)cin>>x[i];
    rep(i,n){
        if(used[i])continue;
        dfs(i);
    }
    rep(i,n){
        cout<<siz[root(i)]<<endl;
    }
}
0