Submission #1069959

#TimeUsernameProblemLanguageResultExecution timeMemory
1069959kiethm07Arranging Shoes (IOI19_shoes)C++14
10 / 100
1090 ms3264 KiB
#include <bits/stdc++.h>

#define pii pair<int,int>
#define iii pair<int,pii>
#define fi first
#define se second

#define vi vector<int>
#define vii vector<pii>
#define pb(i) push_back(i)
#define all(x) x.begin(),x.end()

#define TEXT "a"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int inf = 1e9 + 7;
const ld eps = 1e-8;
const double pi = acos(-1);

ll count_swaps(vector<int> a){
    int n = a.size();
    ll res = 0;
    for (int i = 0; i < n; i += 2){
        int p;
        if (a[i] > 0){
            for (p = i; p < n; p++){
                if (a[p] < 0) break;
            }
            for (int j = p - 1; j >= i; j--){
                swap(a[j], a[j + 1]);
                res++;
            }
        }
        for (p = i + 1; p < n; p++){
            if (a[p] == -a[i]) break;
        }
        for (int j = p - 1; j > i; j--){
            swap(a[j], a[j + 1]);
            res++;
        }
    }
    return res;
}
#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...