QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#131320#2670. Arranging shoessomethingnew#10 25ms4752kbC++201.4kb2023-07-26 22:13:232024-07-04 00:57:45

Judging History

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

  • [2024-07-04 00:57:45]
  • 评测
  • 测评结果:10
  • 用时:25ms
  • 内存:4752kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-26 22:13:23]
  • 提交

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++;
        }
        s.pop_back();
        s.pop_back();
    }
    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

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 3788kb

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

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

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

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

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

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

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

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: 0
Accepted
time: 0ms
memory: 3724kb

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: 0
Accepted
time: 0ms
memory: 3784kb

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: 0
Accepted
time: 0ms
memory: 4048kb

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: 0
Accepted
time: 0ms
memory: 3796kb

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: 0
Accepted
time: 0ms
memory: 4020kb

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: 0
Accepted
time: 0ms
memory: 3792kb

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: 0
Accepted
time: 0ms
memory: 4052kb

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: 0
Accepted
time: 0ms
memory: 4064kb

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: 0
Accepted
time: 0ms
memory: 3864kb

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: 0
Accepted
time: 0ms
memory: 3720kb

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: 0
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: 0
Accepted
time: 0ms
memory: 4056kb

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: 0
Accepted
time: 0ms
memory: 3768kb

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: 0
Accepted
time: 0ms
memory: 3760kb

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: 0
Accepted
time: 0ms
memory: 4064kb

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: 0
Accepted
time: 0ms
memory: 4064kb

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: 0
Accepted
time: 0ms
memory: 4184kb

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: 0
Accepted
time: 3ms
memory: 3888kb

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: 0
Accepted
time: 25ms
memory: 4732kb

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: 0
Accepted
time: 7ms
memory: 4752kb

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: 0
Accepted
time: 15ms
memory: 4716kb

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: -20
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: 0ms
memory: 3764kb

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

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

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: 0
Accepted
time: 0ms
memory: 3792kb

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: -15
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%