QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#658391#2789. SortingPioneer#8 0ms4044kbC++201.1kb2024-10-19 16:44:512024-10-19 16:44:53

Judging History

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

  • [2024-10-19 16:44:53]
  • 评测
  • 测评结果:8
  • 用时:0ms
  • 内存:4044kb
  • [2024-10-19 16:44:51]
  • 提交

answer

#include "sorting.h"
#include <bits/stdc++.h>

using namespace std;

const int MAX=1000;

int n,m,x[MAX],y[MAX];
int s[MAX];

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
	n=N,m=M;
	for(int i=0;i<M;i++)x[i]=X[i],y[i]=Y[i];
	for(int i=0;i<N;i++)s[i]=S[i];
    vector<int> v(n),need(n);
	vector<pair<int,int>> swaps;
	for(int i=0;i<n;i++)v[i]=s[i],need[i]=i;
	for(int i=0;i<m;i++){
		swap(v[x[i]],v[y[i]]);
		vector<int> tov=need;
		for(int j=i+1;j<m;j++){
			swap(tov[x[j]],tov[y[j]]);
		}
		bool ok=0;
		for(int k=0;k<n;k++){
			if(tov[k]!=v[k]){
				for(int j=0;j<n;j++){
					if(tov[j]==v[k]){
						ok=1;
						swaps.push_back({k,j});
						swap(v[k],v[j]);
						break;
					}
				}
				if(ok)break;
			}
		}
		tov=need;
		for(int j=i+1;j<m;j++){
			swap(tov[x[j]],tov[y[j]]);
		}
		// for(int i=0;i<n;i++)cout<<tov[i]<<" "<<v[i]<<"\n";
		// cout<<"\n";
		if(!ok)swaps.push_back({0,0});
	}
	// cout<<"\n";
	assert(v==need);
	for(int i=0;i<m;i++){
		P[i]=swaps[i].first;
		Q[i]=swaps[i].second;
	}
	return M;
}



詳細信息

Subtask #1:

score: 8
Accepted

Test #1:

score: 8
Accepted
time: 0ms
memory: 3800kb

input:

1
0
1
0 0

output:

1
0 0

result:

ok correct

Test #2:

score: 8
Accepted
time: 0ms
memory: 3744kb

input:

2
0 1
4
0 0
0 0
0 0
0 0

output:

4
0 0
0 0
0 0
0 0

result:

ok correct

Test #3:

score: 8
Accepted
time: 0ms
memory: 3796kb

input:

2
1 0
4
0 0
0 0
0 0
0 0

output:

4
0 1
0 0
0 0
0 0

result:

ok correct

Test #4:

score: 8
Accepted
time: 0ms
memory: 3820kb

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:

9
0 1
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0

result:

ok correct

Test #5:

score: 8
Accepted
time: 0ms
memory: 3796kb

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:

16
0 3
0 1
0 2
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

result:

ok correct

Test #6:

score: 8
Accepted
time: 0ms
memory: 4044kb

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:

25
0 1
0 4
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

result:

ok correct

Test #7:

score: 8
Accepted
time: 0ms
memory: 3812kb

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:

25
0 4
0 3
1 2
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

result:

ok correct

Subtask #2:

score: 0
Runtime Error

Test #8:

score: 12
Accepted
time: 0ms
memory: 3760kb

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:

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

result:

ok correct

Test #9:

score: 12
Accepted
time: 0ms
memory: 3816kb

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:

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

result:

ok correct

Test #10:

score: 0
Runtime Error

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:

Unauthorized output

result:


Subtask #3:

score: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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
...

result:

ok correct

Test #15:

score: 0
Runtime Error

input:

96
7 15 12 95 11 50 20 42 81 29 58 80 56 71 63 66 44 6 64 39 2 22 73 1 24 27 69 28 45 25 60 61 5 94 14 65 9 86 68 32 79 37 3 57 34 35 10 88 76 78 21 93 19 53 84 52 4 33 38 55 62 67 77 41 31 48 91 49 51 43 90 8 87 54 16 17 70 46 85 0 75 92 74 47 36 89 30 13 59 26 40 18 82 83 72 23
2880
0 1
0 1
0 1
0 ...

output:

Unauthorized output

result:


Subtask #4:

score: 0
Skipped

Dependency #2:

0%

Subtask #5:

score: 0
Runtime Error

Test #28:

score: 0
Runtime Error

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:

Unauthorized output

result:


Subtask #6:

score: 0
Skipped

Dependency #5:

0%