# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133621 | 2019-07-21T06:54:30 Z | Mahdi_Jfri | Sorting (IOI15_sorting) | C++14 | 18 ms | 380 KB |
#include "sorting.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back const int maxn = 2e5 + 20; int pos[maxn]; int findSwapPairs(int n, int a[], int m, int x[], int y[], int p[], int q[]) { bool f = 1; for(int i = 0; i < n; i++) if(a[i] != i) f = 0; if(f) return 0; swap(a[x[0]] , a[y[0]]); for(int i = 0; i < n; i++) pos[i] = i; for(int i = m - 2; i >= 0; i--) swap(pos[x[i + 1]] , pos[y[i + 1]]); for(int i = 0; i < m; i++) { bool f = 1; for(int j = 0; j < n; j++) if(a[j] != j) f = 0; if(f) return i + 1; for(int j = 0; j < n; j++) if(pos[j] != a[j]) { int ind = -1; for(int k = 0; k < n; k++) if(a[k] == pos[j]) ind = k; while(ind < 0); p[i] = j , q[i] = ind; swap(a[j] , a[ind]); break; } if(i + 1 < m) { swap(pos[x[i + 1]] , pos[y[i + 1]]); swap(a[x[i + 1]] , a[y[i + 1]]); } } return m; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 2 ms | 380 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 2 ms | 380 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 380 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 2 ms | 380 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 18 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 18 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |