# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
63826 | 2018-08-03T04:12:39 Z | 윤교준(#1870) | Ranklist Sorting (BOI07_sorting) | C++11 | 4 ms | 792 KB |
#include <bits/stdc++.h> #define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15); #define pb push_back #define eb emplace_back #define sz(V) ((int)(V).size()) #define befv(V) ((V)[(sz(V)-2)]) #define allv(V) ((V).begin()),((V).end()) #define sorv(V) sort(allv(V)) #define revv(V) reverse(allv(V)) #define univ(V) (V).erase(unique(allv(V)),(V).end()) #define clv(V) (V).clear() #define upmin(a,b) (a)=min((a),(b)) #define upmax(a,b) (a)=max((a),(b)) #define rb(x) ((x)&(-(x))) #define INF (0x3f3f3f3f) #define INFLL (0x3f3f3f3f3f3f3f3fll) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; const bool debug = 0; const int MAXN = 2005; vector<pii> Ans; int A[MAXN]; int N; int main() { ios::sync_with_stdio(false); cin >> N; { vector<int> V; for(int i = 1; i <= N; i++) { cin >> A[i]; V.eb(A[i]); } sorv(V); for(int i = 1; i <= N; i++) A[i] = N - int(lower_bound(allv(V), A[i]) - V.begin()); } if(debug) { for(int i = 1; i <= N; i++) printf("%d ", A[i]); puts(""); } for(int i = N; i; i--) { int idx = -1; for(int j = 1; j <= i; j++) if(i == A[j]) idx = j; if(idx == i) continue; Ans.eb(idx, i); rotate(A+idx, A+idx+1, A+i+1); if(debug) { for(int j = 1; j <= N; j++) printf("%d ", A[j]); puts(""); } } printf("%d\n", sz(Ans)); for(auto &p : Ans) printf("%d %d\n", p.first, p.second); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 488 KB | Output is correct |
3 | Incorrect | 3 ms | 488 KB | Output isn't correct |
4 | Incorrect | 3 ms | 488 KB | Output isn't correct |
5 | Incorrect | 3 ms | 564 KB | Output isn't correct |
6 | Incorrect | 3 ms | 568 KB | Output isn't correct |
7 | Incorrect | 2 ms | 632 KB | Output isn't correct |
8 | Incorrect | 4 ms | 636 KB | Output isn't correct |
9 | Correct | 4 ms | 660 KB | Output is correct |
10 | Incorrect | 3 ms | 792 KB | Output isn't correct |