답안 #830534

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
830534 2023-08-19T07:48:47 Z Minindu206 정렬하기 (IOI15_sorting) C++14
0 / 100
1 ms 340 KB
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[])
{
	int dif = 0;
	vector<int> pos(n, 0);
	for(int i=0;i<n;i++)
	{
		pos[s[i]] = i; 
	}
	int ind = 0;
	for(int i=0;i<n;i++)
	{
		
		// for(int j=0;j<n;j++)
		// 	cout << s[j] <<  " ";
		// cout << '\n';
		if(s[i] != i)
		{
			// cout << i << '\n';
			p[ind] = i;
			q[ind] = pos[i];
			pos[i] = i;
			pos[s[i]] = s[i];
			s[q[ind]] = s[i];
			s[i] = i;
			ind++;
		}
		// for(int j=0;j<n;j++)
		// 	cout << s[j] <<  " ";
		// cout << '\n';
	}
	return ind;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:6:6: warning: unused variable 'dif' [-Wunused-variable]
    6 |  int dif = 0;
      |      ^~~
sorting.cpp:4:39: warning: unused parameter 'm' [-Wunused-parameter]
    4 | int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[])
      |                                   ~~~~^
sorting.cpp:4:46: warning: unused parameter 'x' [-Wunused-parameter]
    4 | int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[])
      |                                          ~~~~^~~
sorting.cpp:4:55: warning: unused parameter 'y' [-Wunused-parameter]
    4 | int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[])
      |                                                   ~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -