QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#296174 | #7951. Magic Cards | defyers# | WA | 0ms | 3672kb | C++17 | 1.3kb | 2024-01-02 13:02:09 | 2024-01-02 13:02:10 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
using ll = long long;
using pii = pair<int, int>;
int n;
int a[200005];
int tr[800005];
int ans[200005];
void build(int p, int l, int r) {
if (l == r) {
tr[p] = 1;
return;
}
int mid = (l + r) / 2;
build(p * 2, l, mid);
build(p * 2 + 1, mid + 1, r);
tr[p] = tr[p * 2] + tr[p * 2 + 1];
return;
}
void qu(int p, int l, int r, int need, int num) {
if (l == r) {
tr[p]--;
ans[l] = num;
return;
}
int mid = (l + r) / 2;
if (need <= tr[p * 2]) {
qu(p * 2, l, mid, need, num);
}
else {
qu(p * 2 + 1, mid + 1, r, need - tr[p * 2], num);
}
tr[p] = tr[p * 2] + tr[p * 2 + 1];
return;
}
void solve(int TC) {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
swap(a[0], a[a[n - 1] % (n - 1)]);
build(1, 0, n - 1);
int p = 0;
ans[n - 1] = a[n - 1];
for (int i = 0; i < n - 1; i++) {
qu(1, 0, n - 1, p, a[i]);
p = (p + a[i] - 1) % (n - i - 1);
}
for (int i = 0; i < n; i++) {
cout << ans[i] << "\n";
}
}
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
cout << fixed << setprecision(10);
int t = 1;
// cin >> t;
for (int i = 1; i <= t; i++) {
solve(i);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3672kb
input:
12 4 6 3 1 9 7 11 3 5 2 10 3 6 7 11 4 5 6 7 6 12 8 11 10 9 12 9 YYNY NNNY YNNN
output:
6 0 5 9 10 7 3 11 3 4 2 3
result:
wrong answer 1st lines differ - expected: '11', found: '6'