제출 #784246

#제출 시각아이디문제언어결과실행 시간메모리
784246HD1Arranging Shoes (IOI19_shoes)C++14
10 / 100
1081 ms212 KiB
//we are all lost trying to be someone.
#include "shoes.h"
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define sz(x) ll(x.size())
#define reve(x) reverse(x.begin(),x.end())
#define ff first
#define ss second
#define pb push_back
using namespace std;
typedef int ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ll, ii >tri;
const ll MAX=1e7+100;
const ll mod=1e9+7;
const ll inf=1e9;
vector<ll> z,s;
map<ll,ll>Mp;
ll cost(ll x, ll aux){
    ll ans=0;
    for(ll i=0; i<sz(z); i++){
        if(z[i]!=x)continue;
        ll pos=i;
        while(pos!=aux){
            pos--;
            swap(z[i],z[i-1]);
            ans++;
        }
        break;
    }
    return ans;
}
ll brute(){
    ll ans=0;
    ll pos=0;
    for(ll i=0; i<sz(s); i++){
        ans+=cost(s[i]*-1,pos);
        pos++;
        ans+=cost(s[i],pos);
        pos++;
    }
    return ans;
}
long long count_swaps(vector<int> c){
    ll mn=1e9;
    for(ll i=2; i<=sz(c); i+=2){
        s.push_back(i/2);
    }
    do{
        z=c;
        mn=min(mn,brute());
    }while(next_permutation(s.begin(),s.end()));
    return mn;
}
#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...