結果

問題 No.1170 Never Want to Walk
ユーザー hamrayhamray
提出日時 2020-08-15 11:00:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,525 bytes
コンパイル時間 2,580 ms
コンパイル使用メモリ 170,124 KB
実行使用メモリ 20,892 KB
最終ジャッジ日時 2024-04-18 23:54:15
合計ジャッジ時間 8,207 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,752 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 WA -
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 4 ms
6,940 KB
testcase_23 AC 3 ms
6,944 KB
testcase_24 AC 3 ms
6,944 KB
testcase_25 AC 4 ms
6,944 KB
testcase_26 AC 4 ms
6,940 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>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

#define EPS 1e-10
//ここから編集
int N, A, B; 
bool visited[200010];
vector<ll> x;
int group[200010];
map<int, int> mp;
vector<int> ababa;
int ans[200010];
int cnt = 0;
void dfs(int v, int p, int k){
  group[v] = k;
  cnt++;
  visited[v] = true;
  {
    auto itr = upper_bound(all(x), x[v]+B);
    itr--;
    
    int idx = mp[*itr];
  
    while(idx < N && x[idx] - x[v] >= A && x[idx] - x[v] <= B ){
    
      if(visited[idx]) {
        break;
      }
      dfs(idx, v, k);
      idx--;
    
    }
  }

  {
    auto itr = upper_bound(all(x), x[v]-B-1);

    int idx = mp[*itr];

    while(idx < N && x[v] - x[idx] >= A && x[v] - x[idx] <= B ){

      if(visited[idx]) {
        idx++;
        continue;
      }
      dfs(idx, v, k);
      idx++;
    }
  }
  
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(6);

  cin >> N >> A >> B;

  x.resize(N);
  REP(i,N) cin >> x[i], mp[x[i]] = i;

  int k = 0;
  for(int i=0; i<N; i++){
    if(visited[i]) continue;
    dfs(i, -1, k);
    ababa.push_back(cnt);
    //cout << i << " " << cnt << endl;
    k++;
    cnt = 0;
  }
  
  for(int i=0; i<N; i++) ans[i] = ababa[group[i]];

  for(int i=0; i<N; i++) cout << ans[i] << endl;
  return 0;
}
0