Submission #883324

#TimeUsernameProblemLanguageResultExecution timeMemory
883324AkibAzmainArranging Shoes (IOI19_shoes)C++17
10 / 100
1087 ms12508 KiB
#include <bits/stdc++.h> using namespace std; #include "shoes.h" long long count_swaps(std::vector<int> a) { int n = a.size (); map < int, int > c; long long ans = 0; for (int i = 0; i < n; ++i) if (c[-a[i]]) { --c[-a[i]]; int j = i; for (; j > 0 && a[j - 1] != -a[j]; --j, ++ans) swap (a[j - 1], a[j]); if (a[j] < 0) swap (a[j - 1], a[j]), ++ans; } else ++c[a[i]]; 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...