# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
557507 | 2022-05-05T12:04:12 Z | MDSPro | 정렬하기 (IOI15_sorting) | C++14 | 4 ms | 460 KB |
// MDSPro #include "sorting.h" #include <bits/stdc++.h> #define trav(i,n) for(int i = 0; i < (n); i++) #define pb push_back #define se second #define fi first #define all(x) (x).begin(),(x).end() using namespace std; using ll = long long; using ld = long double; using pii = pair<int,int>; using vi = vector<int>; const ld PI = 3.141592653589793; const ll MOD = 1e9+7; const int INF = 1e9; const ll INFLL = 4e18; const double EPS = 1e-9; const int SIZE = 1000*1007; int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[]) { auto isSorted = [&n,&s]()->bool{ for(int i = 1; i < n; ++i){ if(s[i-1] > s[i]) return false; } return true; }; int ans = 0; for(int j = 0; j < n; ++j){ if(isSorted()) break; int mn = s[j]; int mni = j; for(int i = j+1; i < n; ++i){ if(mn > s[i]) { mni = i; mn = s[i]; } } swap(s[j],s[mni]); p[j] = j; q[j] = mni; ans++; } for(int i = ans; i < m; ++i) p[i] = q[i] = 0; return ans; } // int main(){ // int n = 5; // int arr[] = {-2,-1,2,0,1}; // for(int i: arr) cout << i << " "; // cout << endl << endl; // int m = 7; // int x[] = {0,0,0,0,0,0,0}; // int y[] = {0,0,0,0,0,0,0}; // int p[m] = {0}; // int q[m] = {0}; // int r = findSwapPairs(n,arr,m,x,y,p,q); // cout << r << " rounds is need!\n"; // for(int i = 0; i < m; ++i){ // cout << "swap " << p[i] << " and " << q[i] << ".\n"; // } // }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 304 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 296 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 304 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 296 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 308 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 312 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 304 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 296 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 308 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 312 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Incorrect | 1 ms | 212 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 460 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 460 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |