QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#354349 | #6437. Paimon's Tree | PorNPtree | WA | 0ms | 3892kb | C++14 | 1.1kb | 2024-03-15 10:41:11 | 2024-03-15 10:41:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, vis[N], s[N];
void modify(int x)
{
for (; x <= n; x += x & -x) {
++s[x];
}
return;
}
int query(int x)
{
int res = 0;
for (; x; x -= x & -x) {
res += s[x];
}
return res;
}
signed main()
{
int T;
scanf("%d", &T);
while (T--) {
int z = 0, a1;
scanf("%d", &n);
long long A = 0;
for (int i = 1; i <= n; ++i) {
vis[i] = s[i] = 0;
}
for (int i = 1, x; i <= n; ++i) {
scanf("%d", &x);
if (i == 1) {
a1 = x;
}
if (!vis[x]) {
modify(x);
vis[x] = 1;
}
if (i > 1 && x == a1) {
++z;
} else if (x > a1) {
A += z + 1;
z = 0;
swap(a1, x);
}
A += query(n) - query(x);
printf("%lld%c", A, " \n"[i == n]);
}
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3892kb
input:
2 5 1 7 3 5 4 1 3 2 3 3 4 4 5 4 6 1 1000000000 1 2
output:
0 1 1 1 2 -2
result:
wrong answer 1st numbers differ - expected: '16', found: '0'