結果
問題 | No.1170 Never Want to Walk |
ユーザー | shiomusubi496 |
提出日時 | 2020-08-14 22:39:32 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 416 ms / 2,000 ms |
コード長 | 1,064 bytes |
コンパイル時間 | 1,629 ms |
コンパイル使用メモリ | 167,076 KB |
実行使用メモリ | 9,728 KB |
最終ジャッジ日時 | 2024-04-18 22:29:04 |
合計ジャッジ時間 | 7,935 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 4 ms
5,376 KB |
testcase_13 | AC | 4 ms
5,376 KB |
testcase_14 | AC | 4 ms
5,376 KB |
testcase_15 | AC | 4 ms
5,376 KB |
testcase_16 | AC | 4 ms
5,376 KB |
testcase_17 | AC | 3 ms
5,376 KB |
testcase_18 | AC | 3 ms
5,376 KB |
testcase_19 | AC | 4 ms
5,376 KB |
testcase_20 | AC | 3 ms
5,376 KB |
testcase_21 | AC | 3 ms
5,376 KB |
testcase_22 | AC | 4 ms
5,376 KB |
testcase_23 | AC | 4 ms
5,376 KB |
testcase_24 | AC | 4 ms
5,376 KB |
testcase_25 | AC | 4 ms
5,376 KB |
testcase_26 | AC | 4 ms
5,376 KB |
testcase_27 | AC | 354 ms
9,344 KB |
testcase_28 | AC | 328 ms
9,344 KB |
testcase_29 | AC | 347 ms
9,600 KB |
testcase_30 | AC | 337 ms
9,472 KB |
testcase_31 | AC | 336 ms
9,344 KB |
testcase_32 | AC | 349 ms
9,344 KB |
testcase_33 | AC | 330 ms
9,472 KB |
testcase_34 | AC | 408 ms
9,344 KB |
testcase_35 | AC | 354 ms
9,344 KB |
testcase_36 | AC | 330 ms
9,472 KB |
testcase_37 | AC | 416 ms
9,344 KB |
testcase_38 | AC | 363 ms
9,728 KB |
ソースコード
#include<bits/stdc++.h> #define int long long using namespace std; struct UnionFind{ int par[10000000],rank[10000000]; int mx[10000000]; UnionFind(int N){ for(int i=0;i<N;i++){ par[i]=i; rank[i]=1; mx[i]=i; } } int find(int x){ if(par[x]==x)return x; int y=find(par[x]); par[x]=y; return y; } void unite(int x,int y){ x=find(x),y=find(y); if(x==y)return; if(rank[x]>=rank[y])par[y]=x,rank[x]+=rank[y],mx[x]=max(mx[x],mx[y]); else par[x]=y,rank[y]+=rank[x],mx[y]=max(mx[x],mx[y]); } bool same(int x,int y){ return find(x)==find(y); } }; signed main(){ int N,A,B; cin>>N>>A>>B; vector<int> V(N); for(int &i:V)cin>>i; UnionFind U(N); for(int i=0;i<N;i++){ int it=lower_bound(V.begin(),V.end(),V[i]+A)-V.begin(); it=max(it,U.mx[U.find(i)]+1); for(int j=it;j<N && V[i]+B>=V[j];j++)U.unite(i,j); } for(int i=0;i<N;i++)cout<<U.rank[U.find(i)]<<endl; }