Submission #243088

#TimeUsernameProblemLanguageResultExecution timeMemory
243088idtjArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
#define int long long
using namespace std;


long long count_swaps(vector<int> S) {
  	int n = S.size() / 2;
    vector<deque<pair<int, int>>> a(n + 1); // pos / is_left
    vector<pair<int, int>> in(n * 2); // size / is_left

    for (int i = 0; i < n * 2; ++i) {
        int now = S[i];
        if (now < 0) {
            in[i].second = 1;
            now = -now;
        }
        in[i].first = now;
    }

    int ans = 0;

    for (int i = 0; i < n * 2; ++i) {
        auto &t = a[abs(in[i].first)];
        if (t.empty() || t.front().second == in[i].second) {
            t.push_back(make_pair(i, in[i].second));
        }
        else {
            if (t.front().second) {
                ans += i - t.front().first - 1;
            }
            else
                ans += i - t.front().first;
            t.pop_front();
        }
    }

	return ans;
}

Compilation message (stderr)

shoes.cpp:5:23: error: 'vector' was not declared in this scope
 long long count_swaps(vector<int> S) {
                       ^~~~~~
shoes.cpp:1:13: error: expected primary-expression before 'long'
 #define int long long
             ^
shoes.cpp:5:30: note: in expansion of macro 'int'
 long long count_swaps(vector<int> S) {
                              ^~~