Submission #66427

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
664272018-08-10 14:17:17Hoget157Sorting (IOI15_sorting)C++14
100 / 100
270 ms12636 KiB
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int n,*a,m,*x,*y,r;
bool C(int k){
int p[200000],ans = 0;
bool used[200000] = {};
for(int i = 0;i < n;i++) p[i] = a[i];
for(int i = 0;i < k;i++) swap(p[x[i]],p[y[i]]);
for(int i = 0;i < n;i++){
if(!used[i]){
int pos = i;
while(!used[pos]){
ans++;
used[pos] = true;
pos = p[pos];
}
ans--;
}
}
return ans <= k;
}
typedef pair<int,int> pii;
int b[200000];
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:57:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(i < vec.size()){
      ~~^~~~~~~~~~~~
sorting.cpp:41:7: warning: unused variable 'used' [-Wunused-variable]
  bool used[200000] = {};
       ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...