제출 #1053806

#제출 시각아이디문제언어결과실행 시간메모리
1053806Osplei정렬하기 (IOI15_sorting)C++17
20 / 100
1 ms600 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; for (int i = 0; i < N; i++) { orden.pb(S[i]); } sort(orden.begin(), orden.end()); for (int i = 0; i < N; i++) { if (orden[i] != S[i]) { ans++; swap(S[X[pos]], S[Y[pos]]); for (int j = i; j < N; j++) { if (orden[i] == S[j]) { swap(S[i], S[j]); P[pos] = i; Q[pos] = j; pos++; break; } } } } for (int i = 0; i < N; i++) { if (orden[i] != S[i]) { ans++; swap(S[X[pos]], S[Y[pos]]); for (int j = i; j < N; j++) { if (orden[i] == S[j]) { swap(S[i], S[j]); P[pos] = i; Q[pos] = j; pos++; break; } } } } for (int i = 0; i < N; i++) { if (orden[i] != S[i]) { ans++; swap(S[X[pos]], S[Y[pos]]); for (int j = i; j < N; j++) { if (orden[i] == S[j]) { swap(S[i], S[j]); P[pos] = i; Q[pos] = j; pos++; break; } } } } if (N != 1 && S[0] > S[1]) { ans++; P[pos] = 0; Q[pos] = 1; pos++; } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:11:43: warning: unused parameter 'M' [-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...