Submission #523836

#TimeUsernameProblemLanguageResultExecution timeMemory
523836pakhomoveeArranging Shoes (IOI19_shoes)C++17
Compilation error
0 ms0 KiB
#include "shoes.h"
#include <cmath>

using namespace std;

long long count_swaps(std::vector<int> s) {
    const int n = s.size();
    long long ans = 0;
    vector<vector<int>> idPlus(n);
    vector<vector<int>> idMinus(n);
    for (int i = 0; i < n; ++i) {
        if (s[i] > 0) {
            idPlus[abs(s[i])].push_back(i);
        } else {
            idMinus[abs(s[i])].push_back(i);
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < idPlus[i].size; ++j) {
            if (idPlus[i][j] < idMinus[i][j]) {
                ans += idMinus[i][j] - idPlus[i][j];
            } else {
                ans += idPlus[i][j] - idMinus[i][j] + 1;
            }
        }
    }
    return ans;
}

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:19:39: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' (did you forget the '()' ?)
   19 |         for (int j = 0; j < idPlus[i].size; ++j) {
      |                                           ()