Submission #523827

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

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

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:8:25: error: 'abs' was not declared in this scope; did you mean 'ans'?
    8 |         for (j = i + 1; abs(s[j]) != abs(s[i]); ++j) {
      |                         ^~~
      |                         ans