답안 #1102981

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1102981 2024-10-19T09:58:50 Z Pioneer 정렬하기 (IOI15_sorting) C++17
0 / 100
4 ms 336 KB
#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();
}


Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:24:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for(int i=0;i<swaps.size();i++){
      |              ~^~~~~~~~~~~~~
sorting.cpp:28:19: warning: conversion from 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   28 |  return swaps.size();
      |         ~~~~~~~~~~^~
sorting.cpp:11:46: warning: unused parameter 'X' [-Wunused-parameter]
   11 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                          ~~~~^~~
sorting.cpp:11:55: warning: unused parameter 'Y' [-Wunused-parameter]
   11 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                                   ~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 0 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 0 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 0 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 0 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -