Submission #217001

#TimeUsernameProblemLanguageResultExecution timeMemory
217001thatprogrammerArranging Shoes (IOI19_shoes)C++14
50 / 100
1097 ms3200 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long count_swaps(vector<int> s) {
    int n = s.size() / 2;
    ll ans = 0;
    for (int i = 0; i < 2 * n; i += 2) {
        int j;
        for (j = i + 1; j < 2 * n; j++) {
            if (s[j] == -s[i]) break;
        }
        if (s[i] < 0)
            ans += j - i - 1;
        else
            ans += j - i;
        for (; j > i; j--) swap(s[j], s[j - 1]);
    }
    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...