結果
| 問題 |
No.1619 Coccinellidae
|
| コンテスト | |
| ユーザー |
nok0
|
| 提出日時 | 2021-07-06 20:46:56 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,096 bytes |
| コンパイル時間 | 2,070 ms |
| コンパイル使用メモリ | 195,884 KB |
| 最終ジャッジ日時 | 2025-01-22 17:52:23 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 WA * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct BIT {
private:
int n, p;
std::vector<T> d;
public:
BIT(int n) : n(n), d(n + 1) {
p = 1;
while(p < n) p *= 2;
}
void add(int i, T x = 1) {
for(i++; i <= n; i += i & -i) d[i] += x;
}
//return sum[0,i)
T sum(int i) {
T res = 0;
for(; i; i -= i & -i) res += d[i];
return res;
}
//return sum[l,r)
T sum(int l, int r) { return sum(r) - sum(l); }
//return min(x) which satisfies (v0 + v1 + ... + vx >= w)
int lower_bound(T w) {
if(w <= 0) return 0;
T x = 0;
for(int i = p; i; i /= 2) {
if(i + x <= n && d[i + x] < w) {
w -= d[i + x];
x += i;
}
}
return x;
}
};
int main() {
int n, m, k;
cin >> n >> m >> k;
BIT<int> BT(n);
for(int i = 0; i < n; i++) BT.add(i, 1);
vector<int> a(n), res(n);
iota(a.begin(), a.end(), 0);
a[n - 1] += m - (long long)n * (n - 1) / 2;
for(int i = 0; i < n; i++) {
int d = min(k, n - 1 - i);
k -= d;
int pl = BT.lower_bound(++d);
BT.add(pl, -1);
res[pl] = a[i];
}
for(const auto &v : res) cout << v << '\n';
return 0;
}
nok0