QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#486734#2670. Arranging shoesDan4Life#10 0ms4008kbC++23854b2024-07-21 23:51:272024-07-21 23:51:27

Judging History

你现在查看的是最新测评结果

  • [2024-07-21 23:51:27]
  • 评测
  • 测评结果:10
  • 用时:0ms
  • 内存:4008kb
  • [2024-07-21 23:51:27]
  • 提交

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);
		upd(i,1); upd(j,-1); upd(j+1,-1);
		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: 3812kb

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: 4008kb

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: 3812kb

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: 3732kb

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: 3784kb

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: 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 #7:

score: -20
Wrong Answer
time: 0ms
memory: 3736kb

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: 3984kb

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: 3732kb

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: 3740kb

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%