結果
| 問題 |
No.1170 Never Want to Walk
|
| コンテスト | |
| ユーザー |
fastmath
|
| 提出日時 | 2020-08-16 22:16:17 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 258 ms / 2,000 ms |
| コード長 | 1,427 bytes |
| コンパイル時間 | 5,403 ms |
| コンパイル使用メモリ | 162,560 KB |
| 実行使用メモリ | 37,504 KB |
| 最終ジャッジ日時 | 2024-10-11 10:44:01 |
| 合計ジャッジ時間 | 10,225 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 37 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
const int N = 2e5+7;
map <int, int> num;
set <int> nu;
int comp[N], cnt[N];
int n, l, r;
void dfs(int x, int c) {
comp[num[x]] = c;
cnt[c]++;
nu.erase(x);
while (1) {
auto t = nu.lower_bound(x - r);
if (t != nu.end() && *t <= x - l) {
dfs(*t, c);
}
else {
break;
}
}
while (1) {
auto t = nu.lower_bound(x + l);
if (t != nu.end() && *t <= x + r) {
dfs(*t, c);
}
else {
break;
}
}
}
signed main() {
#ifdef HOME
freopen("input.txt", "r", stdin);
#else
#define endl '\n'
ios_base::sync_with_stdio(0); cin.tie(0);
#endif
cin >> n >> l >> r;
vector <int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
nu.insert(a[i]);
num[a[i]] = i;
}
int c = 0;
while (nu.size()) {
dfs(*nu.begin(), c++);
}
for (int i = 0; i < n; ++i) {
cout << cnt[comp[i]] << endl;
}
}
fastmath