Submission #831869

# Submission time Handle Problem Language Result Execution time Memory
831869 2023-08-20T16:27:24 Z ttamx Sorting (IOI15_sorting) C++14
0 / 100
2 ms 468 KB
#include "sorting.h"
#include<bits/stdc++.h>

using namespace std;

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;
	for(int i=0;i<n;i++)s.emplace_back(S[i]);
	for(int i=0;i<m;i++)swap(X[i],Y[i]);
	vector<pair<int,int>> ans;
	for(int i=0;i<n;i++){
		while(s[i]!=i){
			ans.emplace_back(i,s[i]);
			swap(s[i],s[s[i]]);
		}
	}
	while(ans.size()<m)ans.emplace_back(0,0);
	for(int i=0;i<m;i++)tie(P[i],Q[i])=ans[i];
	return m;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:20:18: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |  while(ans.size()<m)ans.emplace_back(0,0);
      |        ~~~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -