# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
69395 | 2018-08-20T18:42:32 Z | yusufake | 정렬하기 (IOI15_sorting) | C++ | 537 ms | 13048 KB |
#include<bits/stdc++.h> using namespace std; #include "sorting.h" #define pb push_back #define mp make_pair #define mx 200005 int T[mx],W[mx],A[mx],B[mx],i,l,m,r,t; int findSwapPairs(int n, int *S, int M, int *X, int *Y, int *P, int *Q){ l = 0; r = n; for(; l<r ;){ m = l+r >> 1; for(i=0;i<n;i++){ W[ S[i] ] = i; T[i] = S[i]; P[i] = Q[i] = 0; } for(i=0;i<m;i++) swap(T[ X[i] ], T[ Y[i] ]); t = 0; for(i=0;i<n;i++) for(; T[i] != i ; ){ A[t] = T[ T[i] ]; B[t] = T[i]; t++; swap(T[ T[i] ] , T[i]); } for(i=0;i<n;i++) T[i] = S[i]; for(i=0;i<m;i++){ swap(T[ X[i] ] , T[ Y[i] ]); swap(W[ T[ X[i] ] ] , W[ T[ Y[i] ] ]); if(i >= t) continue; swap(T[ W[ A[i] ] ] , T[ W[ B[i] ] ]); P[i] = W[ A[i] ]; Q[i] = W[ B[i] ]; swap(W[ A[i] ] , W[ B[i] ]); } if(t > m) l = m+1; else r = m; } /// m = l; for(i=0;i<n;i++){ W[ S[i] ] = i; T[i] = S[i]; P[i] = Q[i] = 0; } for(i=0;i<m;i++) swap(T[ X[i] ], T[ Y[i] ]); t = 0; for(i=0;i<n;i++) for(; T[i] != i ; ){ A[t] = T[ T[i] ]; B[t] = T[i]; t++; swap(T[ T[i] ] , T[i]); } for(i=0;i<n;i++) T[i] = S[i]; for(i=0;i<m;i++){ swap(T[ X[i] ] , T[ Y[i] ]); swap(W[ T[ X[i] ] ] , W[ T[ Y[i] ] ]); if(i >= t) continue; swap(T[ W[ A[i] ] ] , T[ W[ B[i] ] ]); P[i] = W[ A[i] ]; Q[i] = W[ B[i] ]; swap(W[ A[i] ] , W[ B[i] ]); } return l; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 304 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 304 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 256 KB | Output is correct |
20 | Correct | 3 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 640 KB | Output is correct |
22 | Correct | 3 ms | 512 KB | Output is correct |
23 | Correct | 3 ms | 512 KB | Output is correct |
24 | Correct | 4 ms | 512 KB | Output is correct |
25 | Correct | 3 ms | 512 KB | Output is correct |
26 | Correct | 3 ms | 512 KB | Output is correct |
27 | Correct | 3 ms | 640 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 512 KB | Output is correct |
2 | Correct | 4 ms | 540 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 512 KB | Output is correct |
8 | Correct | 4 ms | 512 KB | Output is correct |
9 | Correct | 4 ms | 508 KB | Output is correct |
10 | Correct | 3 ms | 512 KB | Output is correct |
11 | Correct | 4 ms | 512 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 512 KB | Output is correct |
2 | Correct | 4 ms | 540 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
6 | Correct | 3 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 512 KB | Output is correct |
8 | Correct | 4 ms | 512 KB | Output is correct |
9 | Correct | 4 ms | 508 KB | Output is correct |
10 | Correct | 3 ms | 512 KB | Output is correct |
11 | Correct | 4 ms | 512 KB | Output is correct |
12 | Correct | 3 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 3 ms | 512 KB | Output is correct |
15 | Correct | 356 ms | 10932 KB | Output is correct |
16 | Correct | 374 ms | 11188 KB | Output is correct |
17 | Correct | 515 ms | 12028 KB | Output is correct |
18 | Correct | 72 ms | 9080 KB | Output is correct |
19 | Correct | 205 ms | 10620 KB | Output is correct |
20 | Correct | 191 ms | 11284 KB | Output is correct |
21 | Correct | 187 ms | 11512 KB | Output is correct |
22 | Correct | 460 ms | 11896 KB | Output is correct |
23 | Correct | 448 ms | 11952 KB | Output is correct |
24 | Correct | 537 ms | 12072 KB | Output is correct |
25 | Correct | 443 ms | 12408 KB | Output is correct |
26 | Correct | 295 ms | 11264 KB | Output is correct |
27 | Correct | 265 ms | 10744 KB | Output is correct |
28 | Correct | 440 ms | 11896 KB | Output is correct |
29 | Correct | 422 ms | 12152 KB | Output is correct |
30 | Correct | 260 ms | 10104 KB | Output is correct |
31 | Correct | 346 ms | 12408 KB | Output is correct |
32 | Correct | 511 ms | 11780 KB | Output is correct |
33 | Correct | 488 ms | 12408 KB | Output is correct |
34 | Correct | 491 ms | 12256 KB | Output is correct |
35 | Correct | 246 ms | 10616 KB | Output is correct |
36 | Correct | 77 ms | 8824 KB | Output is correct |
37 | Correct | 407 ms | 13048 KB | Output is correct |
38 | Correct | 321 ms | 12280 KB | Output is correct |
39 | Correct | 323 ms | 12664 KB | Output is correct |