# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
590888 | 2022-07-06T13:13:52 Z | yutabi | Sorting (IOI15_sorting) | C++14 | 371 ms | 16492 KB |
#include "sorting.h" #include <bits/stdc++.h> using namespace std; #define pb push_back typedef pair <int,int> ii; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { M=N; int l=0; int r=M; int m=(l+r)/2; vector <ii> ans; while(l!=r) { vector <ii> nw; for(int i=0;i<m;i++) { nw.pb(ii(X[i],Y[i])); } int s[N]; int loc[N]; int fnl[N]; int fnl_loc[N]; int temp[N]; for(int i=0;i<N;i++) { s[i]=S[i]; loc[s[i]]=i; temp[i]=s[i]; } for(int i=0;i<nw.size();i++) { swap(temp[nw[i].first],temp[nw[i].second]); } for(int i=0;i<N;i++) { fnl[i]=temp[i]; fnl_loc[fnl[i]]=i; } int ptr=0; while(ptr<N && fnl[ptr]==ptr) { ptr++; } vector <ii> nw_ans; for(int i=0;i<m;i++) { swap(s[nw[i].first],s[nw[i].second]); swap(loc[s[nw[i].first]],loc[s[nw[i].second]]); if(ptr<N) { int num1=ptr; int num2=fnl[ptr]; nw_ans.pb(ii(loc[num1],loc[num2])); swap(s[loc[num1]],s[loc[num2]]); swap(loc[num1],loc[num2]); swap(fnl[fnl_loc[num1]],fnl[fnl_loc[num2]]); swap(fnl_loc[num1],fnl_loc[num2]); } else { nw_ans.pb(ii(0,0)); } while(ptr<N && fnl[ptr]==ptr) { ptr++; } } if(ptr==N) { ans=nw_ans; r=m; } else { l=m+1; } m=(l+r)/2; } for(int i=0;i<m;i++) { P[i]=ans[i].first; Q[i]=ans[i].second; } return m; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 468 KB | Output is correct |
2 | Correct | 2 ms | 468 KB | Output is correct |
3 | Correct | 2 ms | 468 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 2 ms | 364 KB | Output is correct |
8 | Correct | 2 ms | 468 KB | Output is correct |
9 | Correct | 2 ms | 468 KB | Output is correct |
10 | Correct | 2 ms | 468 KB | Output is correct |
11 | Correct | 3 ms | 468 KB | Output is correct |
12 | Correct | 2 ms | 408 KB | Output is correct |
13 | Correct | 2 ms | 468 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 468 KB | Output is correct |
2 | Correct | 2 ms | 468 KB | Output is correct |
3 | Correct | 2 ms | 468 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 2 ms | 364 KB | Output is correct |
8 | Correct | 2 ms | 468 KB | Output is correct |
9 | Correct | 2 ms | 468 KB | Output is correct |
10 | Correct | 2 ms | 468 KB | Output is correct |
11 | Correct | 3 ms | 468 KB | Output is correct |
12 | Correct | 2 ms | 408 KB | Output is correct |
13 | Correct | 2 ms | 468 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 254 ms | 14828 KB | Output is correct |
16 | Correct | 280 ms | 15096 KB | Output is correct |
17 | Correct | 346 ms | 15872 KB | Output is correct |
18 | Correct | 71 ms | 11200 KB | Output is correct |
19 | Correct | 218 ms | 12616 KB | Output is correct |
20 | Correct | 219 ms | 14732 KB | Output is correct |
21 | Correct | 226 ms | 14736 KB | Output is correct |
22 | Correct | 270 ms | 15984 KB | Output is correct |
23 | Correct | 265 ms | 16252 KB | Output is correct |
24 | Correct | 354 ms | 16032 KB | Output is correct |
25 | Correct | 367 ms | 15896 KB | Output is correct |
26 | Correct | 217 ms | 13140 KB | Output is correct |
27 | Correct | 192 ms | 12708 KB | Output is correct |
28 | Correct | 339 ms | 15824 KB | Output is correct |
29 | Correct | 325 ms | 15340 KB | Output is correct |
30 | Correct | 136 ms | 11972 KB | Output is correct |
31 | Correct | 327 ms | 15624 KB | Output is correct |
32 | Correct | 296 ms | 15744 KB | Output is correct |
33 | Correct | 352 ms | 16024 KB | Output is correct |
34 | Correct | 310 ms | 15996 KB | Output is correct |
35 | Correct | 209 ms | 12688 KB | Output is correct |
36 | Correct | 63 ms | 11972 KB | Output is correct |
37 | Correct | 371 ms | 16492 KB | Output is correct |
38 | Correct | 328 ms | 15864 KB | Output is correct |
39 | Correct | 334 ms | 16008 KB | Output is correct |