답안 #432975

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
432975 2021-06-18T16:27:17 Z wiwiho 정렬하기 (IOI15_sorting) C++14
0 / 100
1 ms 332 KB
#include "sorting.h"

#include <bits/stdc++.h>

#define printv(a, b) { \
    for(auto pv : a) b << pv << " "; \
    b << "\n"; \
}
#define mp make_pair
#define F first
#define Sc second
#define eb emplace_back

using namespace std;

typedef long long ll;

using pii = pair<int, int>;

const ll MOD = 1000000007;

int findSwapPairs(int n, int S[], int m, int X[], int Y[], int P[], int Q[]) {

    vector<pii> ans;
    for(int i = 0; i < n; i++){
        while(S[i] != i){
            ans.eb(i, S[i]);
            swap(S[i], S[S[i]]);
        }
    }
    ans.eb(mp(0, 0));

    for(int i = 0; i < ans.size(); i++){
        P[i] = ans[i].F;
        Q[i] = ans[i].Sc;
    }
    
	return ans.size();
}


Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i = 0; i < ans.size(); i++){
      |                    ~~^~~~~~~~~~~~
sorting.cpp:38:17: warning: conversion from 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   38 |  return ans.size();
      |         ~~~~~~~~^~
sorting.cpp:22:39: warning: unused parameter 'm' [-Wunused-parameter]
   22 | int findSwapPairs(int n, int S[], int m, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
sorting.cpp:22:46: warning: unused parameter 'X' [-Wunused-parameter]
   22 | int findSwapPairs(int n, int S[], int m, int X[], int Y[], int P[], int Q[]) {
      |                                          ~~~~^~~
sorting.cpp:22:55: warning: unused parameter 'Y' [-Wunused-parameter]
   22 | int findSwapPairs(int n, int S[], int m, int X[], int Y[], int P[], int Q[]) {
      |                                                   ~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -