Submission #1215748

#TimeUsernameProblemLanguageResultExecution timeMemory
1215748sangerafArranging Shoes (IOI19_shoes)C++20
30 / 100
1095 ms3264 KiB
#include "shoes.h" #include<bits/stdc++.h> using namespace std; long long count_swaps(std::vector<int> s) { int n = s.size()/2; vector<int> v; for(int i=0; i<2*n; i++){ if(s[i] < 0) v.push_back(s[i]); } sort(v.begin(), v.end()); long long valasz = LLONG_MAX; do{ vector<int> uj = s; long long ans = 0; for(int i=0; i<n; i++){ int j = 2*i; while(uj[j] != v[i]) j++; for(int k=j; k>2*i; k--){ ans++; swap(uj[k], uj[k-1]); } j = 2*i+1; while(uj[j] != v[i] * -1) j++; for(int k=j; k>2*i+1; k--){ ans++; swap(uj[k], uj[k-1]); } } valasz = min(valasz, ans); }while(next_permutation(v.begin(), v.end())); return valasz; }
#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...