# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
531667 | 2022-03-01T08:39:14 Z | antonioqbab | Sorting (IOI15_sorting) | C++14 | 1 ms | 300 KB |
#include <bits/stdc++.h> #include <sorting.h> using namespace std; int findSwapPairs(int n, int s[], int m, int x[], int y[], int s1[], int s2[]){ vector<int> p(n); for(int i=0;i<n;++i) p[i]=s[i]; int left=0, right=n-1; auto ok=[&](int pos){ auto p_=p; for(int i=0;i<=pos;++i) swap(p_[x[i]],p_[y[i]]); int ans = n; vector<int> seen(n); for(int i=0;i<n;++i) if(!seen[i]){ --ans; seen[i]=1; for(int j=p_[i];j!=i;j=p_[j]) seen[j]=1; } return ans <= pos+1; }; while(left<right){ int m=(left+right)/2; if(ok(m)) right = m; else left = m + 1; } return left; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 296 KB | Output is correct |
2 | Correct | 1 ms | 296 KB | Output is correct |
3 | Incorrect | 0 ms | 292 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 296 KB | Output is correct |
2 | Correct | 1 ms | 296 KB | Output is correct |
3 | Incorrect | 0 ms | 292 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Incorrect | 1 ms | 208 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 296 KB | Output is correct |
2 | Correct | 1 ms | 296 KB | Output is correct |
3 | Incorrect | 0 ms | 292 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 300 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 300 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |