Submission #694852

#TimeUsernameProblemLanguageResultExecution timeMemory
694852allin27xArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;
ll count_swaps(vector<ll> S){
    ll res = 0;
    ll n = S.size();
    vector<ll> s(n,0);
    vector<bool> ac(n,1);
    for (ll i=0; i<n; i++){
        if (!ac[i]) continue;
        for (ll j=i+1; j<ni; j++){
            if (!ac[j] || abs(S[j])!=abs(S[i])) continue;
            ac[j] = 0;
            ac[i] = 0;
            if (S[i]<0) res+=j-i-1; else res+=j-i; break;
        }
    }
    return res;
}

Compilation message (stderr)

shoes.cpp: In function 'll count_swaps(std::vector<long long int>)':
shoes.cpp:12:26: error: 'ni' was not declared in this scope; did you mean 'i'?
   12 |         for (ll j=i+1; j<ni; j++){
      |                          ^~
      |                          i