QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#348285 | #2670. Arranging shoes | Cyanmond | 10 | 0ms | 4024kb | C++20 | 842b | 2024-03-09 17:42:52 | 2024-03-09 17:42:52 |
Judging History
answer
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using Vec = std::vector<T>;
#define L(i, l, r) for (int i = (l); i < (r); ++i)
#define R(i, l, r) for (int i = (r - 1); i >= (l); --i)
#define sz(s) (int)(std::size(s))
int n;
Vec<int> s;
Vec<int> lpos,rpos;
ll sol() {
ll ret=0;
L(i,0,n)L(j,i+1,n){
int sl = lpos[i],sr=rpos[i],tl=lpos[j],tr=rpos[j];
if(sl>tl){
swap(sl,tl);swap(sr,tr);
}
if(sr<tl)continue;else if(sr<tr)ret+=1;else ret+=2;
}
return ret;
}
long long count_swaps(std::vector<int> s_) {
s=s_;n=sz(s)/2;
lpos.assign(n,0);rpos=lpos;
L(i,0,2*n){
if(s[i]<0)lpos[-s[i] - 1]=i;
else rpos[s[i]-1]=i;
}
ll ans = 0;
L(i,0,n)if(lpos[i]>rpos[i]){
++ans;swap(lpos[i],rpos[i]);
}
ans += sol();
return ans;
}
详细
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 3816kb
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: 3984kb
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: 3744kb
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: 3748kb
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: 3768kb
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: 3720kb
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: 4012kb
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: 0ms
memory: 3772kb
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: 0ms
memory: 3740kb
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: 0ms
memory: 4008kb
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: 0ms
memory: 3736kb
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: 0ms
memory: 3832kb
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: 0ms
memory: 3832kb
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: 0ms
memory: 3820kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 4 -2 3 -4 -3 -2 2 4 2
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 3
result:
wrong answer 3rd lines differ - expected: '7', found: '3'
Subtask #3:
score: 0
Wrong Answer
Test #37:
score: 0
Wrong Answer
time: 0ms
memory: 3804kb
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: 0ms
memory: 3756kb
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: 0ms
memory: 4024kb
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: 3736kb
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: 0ms
memory: 3744kb
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%