답안 #1053730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1053730 2024-08-11T16:23:39 Z Osplei 정렬하기 (IOI15_sorting) C++17
0 / 100
0 ms 348 KB
#include "sorting.h"
#include <bits/stdc++.h>

using namespace std;

#define pb push_back

typedef long long ll;
typedef pair <ll, ll> LL;
ll mod = 1e9 + 7;

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
  P[0] = 0;
	Q[0] = 0;

  vector <int> values;
  int ans = 0, pos[N];

  for (ll i = 0; i < N; i++) {
    values.pb(S[i]);
    pos[S[i]] = i;
  }

  sort(values.begin(), values.end());

  for (ll i = 0; i < N; i++) {
    if (values[i] != S[i]) {
      ans++;
      pos[S[i]] = pos[values[i]];
      swap(S[i], S[pos[values[i]]]);
      pos[values[i]] = i;
    }
  }

  return ans;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:21:17: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   21 |     pos[S[i]] = i;
      |                 ^
sorting.cpp:31:24: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   31 |       pos[values[i]] = i;
      |                        ^
sorting.cpp:12:39: warning: unused parameter 'M' [-Wunused-parameter]
   12 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
sorting.cpp:12:46: warning: unused parameter 'X' [-Wunused-parameter]
   12 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                          ~~~~^~~
sorting.cpp:12:55: warning: unused parameter 'Y' [-Wunused-parameter]
   12 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                                   ~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -