QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#658927 | #2789. Sorting | Pioneer# | 20 | 3ms | 4064kb | C++20 | 579b | 2024-10-19 17:58:36 | 2024-10-19 17:58:37 |
Judging History
answer
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX=200000;
int n,m;
vector<int> s;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
n=N,m=M;
vector<pair<int,int>> swaps;
for(int i=0;i<n;i++)s.push_back(S[i]);
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(s[j]==i){
swaps.push_back({i,j});
swap(s[i],s[j]);
}
}
}
for(int i=0;i<n;i++)assert(s[i]==i);
for(int i=0;i<swaps.size();i++){
P[i]=swaps[i].first;
Q[i]=swaps[i].second;
}
return swaps.size();
}
详细
Subtask #1:
score: 8
Accepted
Test #1:
score: 8
Accepted
time: 0ms
memory: 3656kb
input:
1 0 1 0 0
output:
1 0 0
result:
ok correct
Test #2:
score: 8
Accepted
time: 0ms
memory: 3972kb
input:
2 0 1 4 0 0 0 0 0 0 0 0
output:
2 0 0 1 1
result:
ok correct
Test #3:
score: 8
Accepted
time: 0ms
memory: 3708kb
input:
2 1 0 4 0 0 0 0 0 0 0 0
output:
2 0 1 1 1
result:
ok correct
Test #4:
score: 8
Accepted
time: 0ms
memory: 3696kb
input:
3 1 0 2 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
3 0 1 1 1 2 2
result:
ok correct
Test #5:
score: 8
Accepted
time: 0ms
memory: 3980kb
input:
4 3 2 0 1 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
4 0 2 1 3 2 3 3 3
result:
ok correct
Test #6:
score: 8
Accepted
time: 0ms
memory: 3980kb
input:
5 1 4 2 3 0 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
5 0 4 1 4 2 2 3 3 4 4
result:
ok correct
Test #7:
score: 8
Accepted
time: 0ms
memory: 3708kb
input:
5 4 2 1 0 3 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
5 0 3 1 2 2 2 3 4 4 4
result:
ok correct
Subtask #2:
score: 12
Accepted
Test #8:
score: 12
Accepted
time: 0ms
memory: 3980kb
input:
1 0 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
1 0 0
result:
ok correct
Test #9:
score: 12
Accepted
time: 0ms
memory: 3808kb
input:
2 0 1 60 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
2 0 0 1 1
result:
ok correct
Test #10:
score: 12
Accepted
time: 0ms
memory: 3812kb
input:
98 82 70 31 12 27 51 84 90 66 8 49 52 74 91 46 7 96 67 63 85 34 50 87 83 58 78 26 39 77 48 2 55 94 25 61 56 53 13 32 86 72 20 37 73 9 93 65 28 18 11 71 59 88 35 76 40 24 36 33 3 17 29 38 5 21 15 79 30 62 92 45 80 64 95 43 75 97 23 16 57 22 60 41 69 0 42 14 10 47 68 19 4 1 6 44 81 54 89 2940 0 0 0 0 ...
output:
98 0 84 1 92 2 30 3 59 4 91 5 63 6 93 7 15 8 9 9 44 10 87 11 49 12 59 13 37 14 86 15 65 16 78 17 60 18 48 19 90 20 41 21 64 22 80 23 77 24 56 25 33 26 26 27 91 28 47 29 61 30 67 31 67 32 38 33 58 34 41 35 53 36 57 37 42 38 62 39 91 40 55 41 82 42 85 43 74 44 94 45 70 46 86 47 88 48 61 49 87 50 64 51...
result:
ok correct
Test #11:
score: 12
Accepted
time: 0ms
memory: 3992kb
input:
99 8 14 3 0 98 74 18 10 50 93 49 23 80 2 54 79 90 31 66 38 81 36 42 83 39 7 9 71 59 62 67 4 68 5 70 72 34 95 25 27 45 61 97 48 29 15 46 12 87 22 26 63 77 84 11 85 30 24 40 78 41 1 96 69 94 19 6 65 33 13 52 75 88 82 86 20 92 43 89 47 28 73 35 32 53 60 21 16 37 58 44 76 57 56 17 55 91 51 64 2970 0 0 0...
output:
99 0 3 1 61 2 13 3 13 4 31 5 33 6 66 7 25 8 13 9 26 10 25 11 54 12 47 13 69 14 61 15 45 16 87 17 94 18 66 19 65 20 75 21 86 22 49 23 54 24 57 25 38 26 50 27 39 28 80 29 44 30 56 31 94 32 83 33 68 34 36 35 82 36 86 37 88 38 65 39 57 40 58 41 60 42 49 43 77 44 90 45 58 46 46 47 79 48 77 49 65 50 69 51...
result:
ok correct
Test #12:
score: 12
Accepted
time: 0ms
memory: 4012kb
input:
96 12 91 75 59 44 30 52 63 41 13 93 79 82 60 85 78 50 53 57 8 80 67 34 24 87 17 47 33 83 21 81 40 89 49 32 70 26 9 43 7 11 37 94 36 23 28 90 42 35 25 62 56 20 84 55 45 46 22 77 51 0 69 1 31 54 2 3 58 88 76 5 6 65 92 39 66 15 95 10 27 14 86 72 4 68 18 38 19 64 73 71 74 48 29 61 16 2880 0 0 0 0 0 0 0 ...
output:
96 0 60 1 62 2 65 3 66 4 83 5 70 6 71 7 39 8 19 9 37 10 78 11 40 12 60 13 37 14 80 15 76 16 95 17 25 18 85 19 87 20 52 21 29 22 57 23 44 24 44 25 49 26 36 27 79 28 45 29 93 30 70 31 63 32 34 33 79 34 57 35 48 36 43 37 41 38 86 39 74 40 63 41 87 42 47 43 86 44 83 45 55 46 56 47 86 48 92 49 79 50 95 5...
result:
ok correct
Subtask #3:
score: 0
Wrong Answer
Test #13:
score: 16
Accepted
time: 0ms
memory: 3976kb
input:
2 0 1 60 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
output:
2 0 0 1 1
result:
ok correct
Test #14:
score: 0
Wrong Answer
time: 0ms
memory: 3808kb
input:
5 0 4 1 3 2 150 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 ...
output:
5 0 0 1 2 2 4 3 3 4 4
result:
wrong answer the final array is not sorted
Subtask #4:
score: 0
Skipped
Dependency #2:
100%
Accepted
Dependency #3:
0%
Subtask #5:
score: 0
Wrong Answer
Test #28:
score: 0
Wrong Answer
time: 3ms
memory: 4064kb
input:
1800 530 1775 466 953 230 1179 944 752 990 1316 275 1029 158 152 1673 1706 172 115 599 1661 131 699 1112 454 551 1059 291 495 28 67 773 480 839 462 1210 757 879 285 439 3 1429 820 26 1023 942 199 356 625 1705 1421 144 1529 716 7 1485 1027 1599 696 517 1353 456 1389 273 1363 1414 1177 718 41 777 1621...
output:
1800 0 688 1 1504 2 1217 3 39 4 753 5 320 6 1476 7 53 8 1026 9 477 10 1684 11 197 12 1693 13 1546 14 1661 15 277 16 361 17 1336 18 1040 19 1414 20 1149 21 1344 22 1014 23 1758 24 193 25 918 26 42 27 1314 28 28 29 1022 30 804 31 269 32 199 33 860 34 745 35 214 36 955 37 681 38 1309 39 820 40 296 41 6...
result:
wrong answer the final array is not sorted
Subtask #6:
score: 0
Skipped
Dependency #5:
0%