結果

問題 No.1170 Never Want to Walk
ユーザー chacoder1chacoder1
提出日時 2020-08-14 23:01:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 737 bytes
コンパイル時間 2,405 ms
コンパイル使用メモリ 200,600 KB
実行使用メモリ 14,752 KB
最終ジャッジ日時 2024-04-18 22:52:52
合計ジャッジ時間 13,801 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 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 1 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 3 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 4 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 4 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 5 ms
5,376 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 5 ms
5,376 KB
testcase_25 AC 5 ms
5,376 KB
testcase_26 AC 5 ms
5,376 KB
testcase_27 TLE -
testcase_28 AC 1,346 ms
6,016 KB
testcase_29 AC 570 ms
5,376 KB
testcase_30 AC 890 ms
5,376 KB
testcase_31 AC 1,531 ms
6,272 KB
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int n,a,b;
int x[200010];
int d[200010];
int now=0;
void dfs(int k,int t){
  for(int i=now;i<n;i++){
    //cout<<x[i]<<"$"<<x[k]<<endl;
    if(x[i]-x[k]>b) break;
    if(abs(x[i]-x[k])>=a && abs(x[i]-x[k])<=b && d[i]==0){
      d[i]=t;
      if(i==now) now++;
      dfs(i,t);
    }
  }
  return;
}

int main(){
  cin>>n>>a>>b;
  for(int i=0;i<n;i++){
    cin>>x[i];
    d[i]=0;
  }
  int t=1;
  for(int i=0;i<n;i++){
    if(d[i]==0){
      d[i]=t;
      now=i;
      dfs(i,t);
      t++;
    }
    //cout<<i<<"%%"<<t<<endl;
  }
  map<int,int>mp;
  for(int i=0;i<n;i++){
    //cout<<d[i]<<"$"<<endl;
    mp[d[i]]++;
  }
  for(int i=0;i<n;i++){
    cout<<mp[d[i]]<<endl;
  }
  return 0;
}


  
0