QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#486733 | #2670. Arranging shoes | Dan4Life# | 10 | 0ms | 4116kb | C++23 | 817b | 2024-07-21 23:50:06 | 2024-07-21 23:50:07 |
Judging History
answer
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using ll = long long;
using vi = vector<int>;
using ar2 = array<int,2>;
const int mxN = (int)1e5+10;
int n, fen[mxN];
void upd(int x, int v){
for(x++;x<mxN; x+=x&-x)fen[x]+=v;
}
int sum(int x){
int s = 0;
for(x++;x>0;x-=x&-x) s+=fen[x];
return s;
}
map<int,deque<int>> v;
ll count_swaps(vector<int> a) {
n = sz(a); v.clear(); ll ans = 0;
set<ar2> S; S.clear();
for(int i = 0; i < n; i++)
v[a[i]].pb(i), S.insert({i,a[i]});
while(sz(S)){
int i = (*S.begin())[0];
int x = -(*S.begin())[1];
int j = v[x][0]+sum(x);
ans+=j-i-(x>0);
v[x].pop_front();
S.erase(S.begin());
S.erase({j,a[j]});
}
return ans;
}
详细
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 3804kb
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: 0ms
memory: 4032kb
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: 0ms
memory: 3808kb
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: 0ms
memory: 3808kb
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: 0ms
memory: 3804kb
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: 0ms
memory: 3756kb
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: -20
Wrong Answer
time: 0ms
memory: 3780kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -1 2 1 -2
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 3
result:
wrong answer 3rd lines differ - expected: '2', found: '3'
Subtask #3:
score: 0
Wrong Answer
Test #37:
score: 0
Wrong Answer
time: 0ms
memory: 4116kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -2 -2 2 2
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 2
result:
wrong answer 3rd lines differ - expected: '1', found: '2'
Subtask #4:
score: 0
Wrong Answer
Test #74:
score: 15
Accepted
time: 0ms
memory: 4072kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 1 -1 1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 0
result:
ok 3 lines
Test #75:
score: -15
Wrong Answer
time: 0ms
memory: 4104kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -1 -2 1 2
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 2
result:
wrong answer 3rd lines differ - expected: '1', found: '2'
Subtask #5:
score: 0
Skipped
Dependency #2:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%