QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#128024 | #2670. Arranging shoes | He_Ren | 10 | 1ms | 5720kb | C++17 | 1006b | 2023-07-20 14:41:14 | 2023-07-20 14:41:16 |
Judging History
answer
#include<bits/stdc++.h>
#include"shoes.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 2e5 + 5;
struct BIT
{
int tree[MAXN], n;
#define lowbit(x) ((x)&-(x))
inline void update(int x,int k)
{
while(x<=n)
tree[x] += k, x += lowbit(x);
}
inline int query(int x)
{
int res = 0;
while(x)
res += tree[x], x ^= lowbit(x);
return res;
}
inline int query(int l,int r)
{
return l <= r? query(r) - query(l-1): 0;
}
}tree1, tree2;
ll count_swaps(vector<int> a)
{
int n = (int)a.size();
a.insert(a.begin(), 0);
ll ans = 0;
tree1.n = tree2.n = n;
static int bak[MAXN];
for(int i=1; i<=n; ++i)
{
int x = abs(a[i]);
if(!bak[x])
{
if(a[i] > 0) ++ans;
bak[x] = i;
tree1.update(i, 1);
continue;
}
ans += tree1.query(bak[x] + 1, i - 1);
ans += tree2.query(bak[x] + 1, i - 1) * 2;
tree1.update(bak[x], -1);
tree2.update(bak[x], 1);
}
return ans;
}
详细
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 1ms
memory: 3744kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 1 -1 1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 0
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 3696kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 1 1 -1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 1
result:
ok 3 lines
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #3:
score: 20
Accepted
time: 1ms
memory: 3736kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -1 -2 2 1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 2
result:
ok 3 lines
Test #4:
score: 0
Accepted
time: 1ms
memory: 3784kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -2 1 -1 2
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 3
result:
ok 3 lines
Test #5:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -2 2 -1 1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 0
result:
ok 3 lines
Test #6:
score: 0
Accepted
time: 1ms
memory: 3800kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -1 -2 2 1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 2
result:
ok 3 lines
Test #7:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -1 2 1 -2
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 2
result:
ok 3 lines
Test #8:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 2 -2 -1 1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 1
result:
ok 3 lines
Test #9:
score: 0
Accepted
time: 1ms
memory: 3784kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 1 2 -2 -1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 4
result:
ok 3 lines
Test #10:
score: 0
Accepted
time: 1ms
memory: 3744kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 2 -2 1 -1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 2
result:
ok 3 lines
Test #11:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 1 2 -2 -1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 4
result:
ok 3 lines
Test #12:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 3 -3 -2 1 2 3 -1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 5
result:
ok 3 lines
Test #13:
score: 0
Accepted
time: 1ms
memory: 3608kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 4 -1 1 -2 2 -4 4 -3 3
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 0
result:
ok 3 lines
Test #14:
score: -20
Wrong Answer
time: 1ms
memory: 3736kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 4 -2 3 -4 -3 -2 2 4 2
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 12
result:
wrong answer 3rd lines differ - expected: '7', found: '12'
Subtask #3:
score: 0
Wrong Answer
Test #37:
score: 0
Wrong Answer
time: 1ms
memory: 3724kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -2 -2 2 2
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 0
result:
wrong answer 3rd lines differ - expected: '1', found: '0'
Subtask #4:
score: 0
Wrong Answer
Test #74:
score: 15
Accepted
time: 1ms
memory: 3608kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 1 -1 1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 0
result:
ok 3 lines
Test #75:
score: 0
Accepted
time: 1ms
memory: 5720kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -1 -2 1 2
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 1
result:
ok 3 lines
Test #76:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -2 -1 2 1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 1
result:
ok 3 lines
Test #77:
score: -15
Wrong Answer
time: 1ms
memory: 3796kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -1 -1 1 1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 0
result:
wrong answer 3rd lines differ - expected: '1', found: '0'
Subtask #5:
score: 0
Skipped
Dependency #2:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%