Submission #147030

#TimeUsernameProblemLanguageResultExecution timeMemory
147030DenisovArranging Shoes (IOI19_shoes)C++14
50 / 100
1078 ms3220 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long ll count_swaps(vector<int> a) { ll ans = 0; int n = (int)a.size(); for (int i = 0; i < n; ) { while (i < n && -a[i] == a[i + 1]) { if (a[i + 1] < a[i]) { swap(a[i + 1], a[i]); ++ans; } i += 2; } if (i >= n) break; int j = i + 2; while (-a[j] != a[i]) { ++j; } for (; j > i + 1; j--) { swap(a[j], a[j - 1]); ++ans; } if (a[i + 1] < a[i]) { swap(a[i + 1], a[i]); ++ans; } } return ans; }
#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...