Submission #1053749

#TimeUsernameProblemLanguageResultExecution timeMemory
1053749OspleiSorting (IOI15_sorting)C++17
0 / 100
1 ms348 KiB
#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, aux; 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++; aux = S[0]; S[0] = S[1]; S[1] = aux; for (ll j = 0; j < N; j++) { if (orden[i] == S[j]) { aux = S[i]; S[i] = S[j]; S[j] = aux; P[pos] = i; Q[pos] = j; pos++; break; } } } } if (S[0] > S[1]) { ans++; P[pos] = 0; Q[pos] = 1; pos++; } return ans; }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:38:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   38 |           P[pos] = i;
      |                    ^
sorting.cpp:39:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   39 |           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[]) {
      |                                                   ~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...