QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#805731 | #9792. Ogre Sort | ucup-team5008# | WA | 0ms | 3688kb | C++23 | 612b | 2024-12-08 18:13:16 | 2024-12-08 18:13:18 |
Judging History
answer
#include <cstdio>
const int N = 300005;
int n, a[N], pos[N], b[N];
void add(int i, int d) {
while (i <= n) {
b[i] += d;
i |= i + 1;
}
}
int query(int i) {
int s = 0;
while (i >= 0) {
s += b[i];
i = (i & i + 1) - 1;
}
return s;
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d", a + i);
pos[a[i]] = i;
}
int l = n;
while (l && a[l - 1] == l) --l;
if (!l) printf("0 0\n");
else {
printf("%d %d\n", l - 1, l - 1);
for (int i = l - 1; i >= 1; --i) {
printf("%d %d\n", pos[i] + (l - 1 - i) - query(pos[i]) + 1, 1);
add(pos[i] + 1, 1);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 1624kb
input:
4 1 2 4 3
output:
3 3 4 1 3 1 3 1
result:
ok Participant's output is correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
5 2 4 1 3 5
output:
3 3 4 1 2 1 4 1
result:
ok Participant's output is correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
3 1 2 3
output:
0 0
result:
ok Participant's output is correct
Test #4:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
4 1 2 4 3
output:
3 3 4 1 3 1 3 1
result:
ok Participant's output is correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
5 2 4 1 3 5
output:
3 3 4 1 2 1 4 1
result:
ok Participant's output is correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
3 1 2 3
output:
0 0
result:
ok Participant's output is correct
Test #7:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
1 1
output:
0 0
result:
ok Participant's output is correct
Test #8:
score: 0
Accepted
time: 0ms
memory: 1588kb
input:
5 5 3 4 1 2
output:
4 4 3 1 3 1 5 1 5 1
result:
ok Participant's output is correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
5 4 1 2 3 5
output:
3 3 4 1 4 1 4 1
result:
ok Participant's output is correct
Test #10:
score: -100
Wrong Answer
time: 0ms
memory: 3688kb
input:
5 1 3 4 2 5
output:
3 3 2 1 4 1 3 1
result:
wrong answer Integer parameter [name=participant answer] equals to 3, violates the range [0, 2]