제출 #523826

#제출 시각아이디문제언어결과실행 시간메모리
523826pakhomoveeArranging Shoes (IOI19_shoes)C++17
컴파일 에러
0 ms0 KiB
#include "shoes.h" long long count_swaps(std::vector<int> s) { 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; }

컴파일 시 표준 에러 (stderr) 메시지

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