답안 #1053740

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1053740 2024-08-11T16:38:42 Z Osplei 정렬하기 (IOI15_sorting) C++17
20 / 100
1 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;

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

  vector <int> orden;
  int ans = 0, pos = 0;

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

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

  for (ll i = 0; i < N; i++) {
    if (orden[i] != S[i]) {
      ans++;
      for (ll j = i + 1; j < N; j++) {
        if (orden[i] == S[j]) {
          int aux = S[i];
          S[i] = S[j];
          S[j] = aux;
          P[pos] = i;
          Q[pos] = j;
          pos++;
          break;
        }
      }
    }
  }

  return ans;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:30:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   30 |           P[pos] = i;
      |                    ^
sorting.cpp:31:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   31 |           Q[pos] = j;
      |                    ^
sorting.cpp:11:39: warning: unused parameter 'M' [-Wunused-parameter]
   11 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
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 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -