Submission #1215273

#TimeUsernameProblemLanguageResultExecution timeMemory
1215273ColourAttilaArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
long long count_swaps_subt2(vector<int>v){
    ll n = (ll)v.size();
    vector<int> e;
    for(auto i : v) if(i < 0) e.push_back(i);
    sort(e.begin(), e.end());
    ll cv = 1e9;
    do{
        vector<int>p;
        for(ll i = 0; i < e.size(); i ++) p.push_back(e[i]), p.push_back(-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(e.begin(), e.end()));
    return cv;
}

Compilation message (stderr)

shoes.cpp:1:29: error: 'vector' was not declared in this scope
    1 | long long count_swaps_subt2(vector<int>v){
      |                             ^~~~~~
shoes.cpp:1:36: error: expected primary-expression before 'int'
    1 | long long count_swaps_subt2(vector<int>v){
      |                                    ^~~