# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
317885 | 2020-10-30T17:14:36 Z | wildturtle | Sorting (IOI15_sorting) | C++14 | 1 ms | 544 KB |
#include <bits/stdc++.h> #include "sorting.h" using namespace std; int a,le,ri,ans,mid; vector <int> S1,A; vector < pair < int , int > > v; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { le=0; ri=M; ans=-1; while(le<=ri) { mid=(le+ri)/2; for(int i=0;i<N;i++) S1[i]=S[i]; for(int i=0;i<mid;i++) { swap(S1[X[i]],S1[Y[i]]); } for(int i=0;i<N;i++) { A[S1[i]]=i; } v.clear(); for(int i=0;i<N;i++) { if(S1[i]==i) continue; v.push_back({i,S1[i]}); } a=v.size(); if(a<=mid) { for(int i=0;i<N;i++) { S1[i]=S[i]; A[S1[i]]=i; } for(int i=0;i<M;i++) { swap(A[S1[X[i]]],A[S1[Y[i]]]); swap(S1[X[i]],S1[Y[i]]); if(i<a) { P[i]=A[v[i].first]; Q[i]=A[v[i].second]; swap(A[S1[P[i]]],A[S1[Q[i]]]); swap(S1[P[i]],S1[Q[i]]); } else { P[i]=0; Q[i]=0; } } ri=mid-1; ans=mid; } else le=mid+1; } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 544 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 544 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |