QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#131324 | #2670. Arranging shoes | somethingnew# | 10 | 29ms | 4912kb | C++20 | 1.5kb | 2023-07-26 22:17:15 | 2024-07-04 00:57:45 |
Judging History
answer
// ↘ ⬇ ⬇ ⬇ ⬇ ⬇ ↙
// ➡ @roadfromroi ⬅
// ↗ ⬆ ⬆ ⬆ ⬆ ⬆ ↖
#include <iostream>
#include "vector"
#include "algorithm"
#include "numeric"
#include "climits"
#include "iomanip"
#include "bitset"
#include "cmath"
#include "map"
#include "deque"
#include "array"
#include "set"
#include "shoes.h"
#define all(x) x.begin(), x.end()
using namespace std;
//#define LOCAL 1
long long count_swaps(vector<int> s) {
int res = 0;
while (!s.empty()) {
int i = s.size() - 1;
for (; i >= 0; --i) {
if (s[i] > 0)
break;
}
while (i + 1 != s.size()) {
res++;
swap(s[i], s[i + 1]);
i++;
}
int k = -s.back();
for (; i >= 0; --i) {
if (s[i] == k)
break;
}
while (i + 2 != s.size()) {
res++;
swap(s[i], s[i + 1]);
i++;
}
if (s[i] == -s[i+1]) {
s.pop_back();
s.pop_back();
} else {exit(1);}
}
return res;
}
#ifdef LOCAL
int main() {
int n;
assert(1 == scanf("%d", &n));
vector<int> S(2 * n);
for (int i = 0; i < 2 * n; i++)
assert(1 == scanf("%d", &S[i]));
fclose(stdin);
long long result = count_swaps(S);
printf("%lld\n", result);
fclose(stdout);
return 0;
}
#endif
詳細信息
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 1ms
memory: 3708kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 1 -1 1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 0
result:
ok 3 lines
Test #2:
score: 10
Accepted
time: 1ms
memory: 3832kb
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: 3712kb
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: 20
Accepted
time: 1ms
memory: 3996kb
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: 20
Accepted
time: 0ms
memory: 3708kb
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: 20
Accepted
time: 0ms
memory: 3760kb
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
Wrong Answer
time: 0ms
memory: 3708kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -1 2 1 -2
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 4
result:
wrong answer 3rd lines differ - expected: '2', found: '4'
Subtask #3:
score: 0
Time Limit Exceeded
Test #37:
score: 20
Accepted
time: 0ms
memory: 3752kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -2 -2 2 2
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 1
result:
ok 3 lines
Test #38:
score: 20
Accepted
time: 0ms
memory: 3704kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -1 1 -1 1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 0
result:
ok 3 lines
Test #39:
score: 20
Accepted
time: 1ms
memory: 3708kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -1 1 -1 1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 0
result:
ok 3 lines
Test #40:
score: 20
Accepted
time: 0ms
memory: 3844kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -2 -2 2 2
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 1
result:
ok 3 lines
Test #41:
score: 20
Accepted
time: 0ms
memory: 3844kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -1 1 1 -1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 1
result:
ok 3 lines
Test #42:
score: 20
Accepted
time: 1ms
memory: 3712kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 2 -2 -2 2
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 1
result:
ok 3 lines
Test #43:
score: 20
Accepted
time: 0ms
memory: 3776kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 1 1 -1 -1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 3
result:
ok 3 lines
Test #44:
score: 20
Accepted
time: 0ms
memory: 3728kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 2 -2 2 -2
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 2
result:
ok 3 lines
Test #45:
score: 20
Accepted
time: 0ms
memory: 3728kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 1 1 -1 -1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 3
result:
ok 3 lines
Test #46:
score: 20
Accepted
time: 0ms
memory: 3756kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 3 2 -2 -2 2 -2 2
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 1
result:
ok 3 lines
Test #47:
score: 20
Accepted
time: 1ms
memory: 3964kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 8 -3 -3 -3 3 -3 -3 -3 3 3 3 3 3 3 3 -3 -3
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 15
result:
ok 3 lines
Test #48:
score: 20
Accepted
time: 0ms
memory: 3844kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 11 5 5 -5 5 5 -5 -5 5 5 -5 5 -5 -5 5 -5 -5 -5 -5 5 5 -5 5
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 19
result:
ok 3 lines
Test #49:
score: 20
Accepted
time: 1ms
memory: 4008kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 43 -35 -35 -35 35 35 -35 -35 -35 35 -35 35 -35 35 35 -35 35 35 -35 -35 35 35 35 -35 -35 -35 35 -35 35 -35 35 35 35 35 35 35 35 -35 35 -35 -35 -35 -35 35 35 35 35 -35 35 -35 35 35 -35 -35 -35 35 35 -35 35 -35 35 35 -35 35 35 35 35 -35 -35 -35 -35 -35 35 -35 -35 -3...
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 117
result:
ok 3 lines
Test #50:
score: 20
Accepted
time: 0ms
memory: 3708kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 117 50 -50 -50 -50 50 50 -50 50 -50 -50 50 50 50 50 50 -50 -50 -50 50 -50 50 -50 50 50 50 50 50 50 50 -50 50 50 50 -50 -50 -50 50 50 -50 -50 50 50 50 -50 -50 -50 -50 -50 50 -50 50 -50 -50 50 -50 50 50 50 -50 50 -50 50 50 50 50 50 -50 50 50 -50 50 50 -50 50 -50 -5...
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 1000
result:
ok 3 lines
Test #51:
score: 20
Accepted
time: 0ms
memory: 4004kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 304 -44 -44 44 44 44 -44 -44 44 44 44 44 -44 -44 -44 44 -44 44 44 -44 -44 44 44 44 -44 -44 -44 -44 44 -44 44 -44 44 44 -44 -44 -44 44 44 -44 44 44 44 -44 -44 44 44 44 44 44 -44 44 44 -44 -44 -44 44 -44 44 -44 44 -44 -44 -44 -44 -44 -44 -44 44 -44 -44 44 44 -44 -4...
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 1711
result:
ok 3 lines
Test #52:
score: 20
Accepted
time: 1ms
memory: 3976kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 999 -636 636 636 -636 636 636 -636 636 -636 636 -636 636 -636 636 -636 636 -636 636 -636 -636 -636 636 636 -636 -636 -636 636 -636 636 -636 -636 -636 -636 636 -636 -636 636 -636 636 636 -636 -636 -636 636 -636 -636 -636 -636 636 636 636 636 636 -636 -636 -636 -63...
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 19586
result:
ok 3 lines
Test #53:
score: 20
Accepted
time: 1ms
memory: 3768kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 1001 -498 -498 -498 -498 -498 -498 -498 -498 -498 -498 -498 498 -498 -498 -498 -498 498 -498 -498 -498 498 -498 498 498 498 498 -498 498 -498 498 -498 -498 498 -498 -498 498 -498 498 -498 -498 498 -498 498 498 498 498 -498 -498 -498 498 498 -498 -498 498 -498 -49...
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 29174
result:
ok 3 lines
Test #54:
score: 20
Accepted
time: 2ms
memory: 3828kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 9998 -1466 1466 1466 1466 1466 1466 -1466 1466 1466 -1466 1466 1466 1466 1466 -1466 -1466 1466 1466 -1466 1466 -1466 -1466 1466 -1466 1466 -1466 -1466 1466 -1466 1466 -1466 -1466 -1466 -1466 1466 1466 1466 1466 -1466 -1466 -1466 -1466 -1466 -1466 -1466 1466 -1466...
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 434563
result:
ok 3 lines
Test #55:
score: 20
Accepted
time: 3ms
memory: 4136kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 10003 -9391 -9391 9391 9391 -9391 -9391 -9391 9391 9391 9391 -9391 -9391 9391 -9391 9391 -9391 -9391 -9391 -9391 9391 -9391 9391 -9391 9391 -9391 -9391 9391 -9391 -9391 9391 9391 9391 9391 -9391 -9391 -9391 -9391 -9391 9391 -9391 -9391 -9391 9391 -9391 -9391 9391...
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 662066
result:
ok 3 lines
Test #56:
score: 20
Accepted
time: 29ms
memory: 4604kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 99999 -20650 -20650 20650 20650 -20650 -20650 -20650 20650 20650 20650 -20650 -20650 20650 20650 20650 20650 20650 20650 -20650 20650 20650 -20650 20650 20650 20650 20650 20650 -20650 20650 20650 20650 -20650 -20650 20650 20650 -20650 -20650 20650 20650 20650 206...
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 9148558
result:
ok 3 lines
Test #57:
score: 20
Accepted
time: 14ms
memory: 4664kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 100000 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11332 -11332 11...
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 0
result:
ok 3 lines
Test #58:
score: 20
Accepted
time: 17ms
memory: 4912kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 100000 26704 -26704 -26704 26704 26704 -26704 26704 -26704 26704 -26704 26704 -26704 26704 -26704 -26704 26704 -26704 26704 -26704 26704 -26704 26704 -26704 26704 26704 -26704 -26704 26704 -26704 -26704 -26704 -26704 26704 26704 -26704 26704 26704 -26704 26704 26...
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 1233583
result:
ok 3 lines
Test #59:
score: 0
Time Limit Exceeded
input:
08f55b3f-c300-4051-a472-59ca2a776178 100000 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1966 1...
output:
Unauthorized output
result:
Subtask #4:
score: 0
Time Limit Exceeded
Test #74:
score: 15
Accepted
time: 1ms
memory: 3752kb
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
Accepted
time: 1ms
memory: 3708kb
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: 15
Accepted
time: 0ms
memory: 3712kb
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
Accepted
time: 0ms
memory: 3712kb
input:
08f55b3f-c300-4051-a472-59ca2a776178 2 -1 -1 1 1
output:
9ce55564-5404-428a-8d2e-0d809c85101e OK 1
result:
ok 3 lines
Test #78:
score: 0
Time Limit Exceeded
input:
08f55b3f-c300-4051-a472-59ca2a776178 99998 -93375 -85998 -57472 -57320 -92144 -31526 -99604 -77181 -65443 -97629 -29716 -1904 -93293 -41761 -55949 -50927 -80082 -21357 -51929 -54 -33477 -36300 -49484 -70830 -98314 -40123 -79568 -89806 -90528 -51711 -49394 -2023 -42435 -61625 -61156 -82943 -47590 -69...
output:
Unauthorized output
result:
Subtask #5:
score: 0
Skipped
Dependency #2:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%