結果

問題 No.1170 Never Want to Walk
ユーザー chacoder1chacoder1
提出日時 2020-08-14 22:41:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 622 bytes
コンパイル時間 2,242 ms
コンパイル使用メモリ 201,052 KB
実行使用メモリ 13,884 KB
最終ジャッジ日時 2024-04-18 22:32:44
合計ジャッジ時間 6,248 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
13,884 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 0 ms
6,940 KB
testcase_08 WA -
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
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];
void dfs(int k,int t){
  for(int i=k+1;i<n;i++){
    //cout<<x[i]<<"$"<<x[k]<<endl;
    if(abs(x[i]-x[k])>=a && abs(x[i]-x[k])<=b){
      d[i]=t;
      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;
      dfs(i,t);
      t++;
    }
    //cout<<i<<"%%"<<t<<endl;
  }
  map<int,int>mp;
  for(int i=0;i<n;i++){
    mp[d[i]]++;
  }
  for(int i=0;i<n;i++){
    cout<<mp[d[i]]<<endl;
  }
  return 0;
}


  
0