Submission #1206544

#TimeUsernameProblemLanguageResultExecution timeMemory
1206544al95ireyizArranging Shoes (IOI19_shoes)C++20
30 / 100
1096 ms3904 KiB
//*** Bismillah ***//
#pragma GCC optimize("O3", "fast-math", "unroll-loops", "no-stack-protector")
#include <bits/stdc++.h>
using namespace std;
#if !defined(ONLINE_JUDGE) and !defined(EVAL)
#include "template/debug.h"
#else
#define d(x...)
#endif
#define fr first
#define er erase
#define sc second
#define in insert
#define ll long long
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define ull unsigned ll
#define vpll vector<pll>
#define len(x)(ll)x.size()
#define all(x)x.begin(),x.end()
const ll INF = 1e9;
const ll INFL = 1e18;
const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll maxn = 2e5+5;
ll n,m,k=0;
ll count_swaps(vector<int>v){
    n = len(v);
    vector<int> e;
    for(auto i : v) if(i < 0) e.pb(i);
    sort(all(e));
    ll cv = INF;
    do{
        vector<int>p;
        for(ll i = 0; i < len(e); i ++) p.pb(e[i]), p.pb(-e[i]);
        ll say = 0;
        vector<int> a = v;
        for(ll i = 0; i < n; i ++){
            if(a[i] == p[i]) continue;
            ll j;
            for(j = i + 1; j < n; j ++){
                if(a[j] == p[i]) break;
            }
            for(; j > i; j --){
                say ++;
                a[j] = a[j - 1];
            }
            a[i] = p[i];
        }
        cv = min(cv, say);
    }while(next_permutation(all(e)));
    return cv;
}
// void _(ll tt){

// }
// signed main(){
//     ll tm=clock();
//     cin.tie(0)->sync_with_stdio(0);
//     ll t=1;
//     // cin>>t;
//     for(ll tt=1;tt<=t;tt++){
//         _(tt);
//     }
//     cerr<<"\n\033[1;31mTime: \033[1;30m" \
//         <<(double)(clock()-tm)/1000000<<"\033[1;32m seconds\n";
// }
#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...