QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#639010 | #9249. Elimination Series Once More | blue_sky | WA | 0ms | 3856kb | C++20 | 1.7kb | 2024-10-13 17:38:51 | 2024-10-13 17:38:54 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define bug(X) cout << "bug:# " << X << endl
#define bug2(f, X) cout << "bug:# " << f << " " << X << endl
#define bug3(i, j, G) cout << "bug:# " << i << ' ' << j << ' ' << G << endl
#define endl '\n'
using namespace std;
const int mod = 1e11 + 3;
const int N = 10 + 5e5;
void _();
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
_();
return 0;
}
int mi(int n)
{
return 1ll << n;
}
struct Node
{
int x, idx, res;
};
int get(int n)
{
int k = 0;
while (n)
n >>= 1, k++;
return k;
}
void _()
{
int n, k;
cin >> n >> k;
vector<int> tr(mi(2 * n));
vector<Node> a(mi(n));
for (int i = 1; i <= mi(n); i++)
{
cin >> a[i - 1].x;
a[i - 1].idx = i;
}
sort(a.begin(), a.end(), [](Node &a, Node &b)
{ return a.x < b.x; });
int sum_ceng = get(n);
auto to_d = [&](int n)
{
return sum_ceng - get(n) + 1;
};
auto need = [&](int n)
{
int t = to_d(n);
return mi(t) - 1;
};
for (auto &[x, idx, res] : a)
{
int st = idx;
int win = 0;
while (st)
{
if (tr[st] + min(k, idx - 1 - tr[st]) >= need(st))
win = to_d(st);
st >>= 1;
}
res = win;
st = idx;
while (st)
{
tr[st]++;
st >>= 1;
}
}
sort(a.begin(), a.end(), [](Node &a, Node &b)
{ return a.idx < b.idx; });
for (auto [a, b, c] : a)
cout << c << ' ';
cout << endl;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3784kb
input:
2 1 1 2 3 4
output:
0 1 1 2
result:
ok 4 number(s): "0 1 1 2"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3856kb
input:
3 5 2 4 7 5 3 8 6 1
output:
0 1 1 2 2 2 2 2
result:
wrong answer 1st numbers differ - expected: '1', found: '0'