Submission #685055

#TimeUsernameProblemLanguageResultExecution timeMemory
685055turbatArranging Shoes (IOI19_shoes)C++14
50 / 100
1084 ms3112 KiB
#include "shoes.h" using namespace std; long long count_swaps(vector<int> s) { int n = s.size(), ans = 0; for (int i = 0; i < n; i += 2) { int pos = i; for (int j = i; j < n; j++) if (s[j] == -s[i]) { pos = j; break; } for (int j = pos; j > i + 1; j--) { if (s[j] == -s[i]) { swap(s[j], s[j - 1]); ans++; } } if (s[i] > 0) { swap(s[i], s[i + 1]); 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...