結果
| 問題 | 
                            No.1170 Never Want to Walk
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ricoriser32
                         | 
                    
| 提出日時 | 2020-08-19 11:05:06 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,489 bytes | 
| コンパイル時間 | 2,330 ms | 
| コンパイル使用メモリ | 195,748 KB | 
| 最終ジャッジ日時 | 2025-01-13 03:42:19 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 30 TLE * 7 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<ll(n); i++)
#define REPR(i, n) for(ll i=n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=m; i<ll(n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 2e9;
const ll LINF = (1LL<<60);
struct UnionFind {
  vector<int> par;
   
  UnionFind(int n) : par(n, -1) { }
  void init(int n) { par.assign(n, -1); }
   
  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }
    
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
    
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y); // merge technique
    par[x] += par[y];
    par[y] = x;
    return true;
  }
    
  int size(int x) {
    return -par[root(x)];
  }
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,a,b;
  cin >> n >> a >> b;
  vector<int> x(n);
  REP(i,n) cin >> x[i];
  UnionFind tree(n);
  REP(i,n-1){
    int left = lower_bound(ALL(x), x[i]+a) - x.begin();
    int right = upper_bound(ALL(x), x[i]+b) - x.begin();
    FOR(j,left, right){
      tree.merge(i, j);
    }
  }
  REP(i,n) cout << tree.size(i) << '\n';
  return 0;
}
            
            
            
        
            
ricoriser32