Submission #468816

#TimeUsernameProblemLanguageResultExecution timeMemory
468816PiejanVDCArranging Shoes (IOI19_shoes)C++17
50 / 100
1093 ms1856 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int>v) { int fixed = -1, n = v.size(); long long ans = 0; while(fixed < n-1) { int fix = -v[fixed+1]; int pos = fixed+2; while(pos < n && v[pos] != fix) pos++; for(int i = pos-1 ; i > fixed+1 ; i--) ans++,swap(v[i],v[i+1]); if(fix < 0) { ans++; swap(v[fixed+1],v[fixed+2]); } fixed+=2; } return ans; } /* signed main() { int n; cin>>n; vector<int>v(n); for(auto &z : v) cin >> z; cout << count_swaps(v); } */
#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...