제출 #965368

#제출 시각아이디문제언어결과실행 시간메모리
965368akacool445kArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include "shoes.h" long long count_swaps(std::vector<int> s) { long long n = s.size(); long long ans = 0; vector<int> c(n, 1); for (int i = 0; i < n; i++) { if (c[i] == 0) continue; int ss = 0; for (int j = i + 1; j < n; j++) { if (s[i] + s[j] == 0) { ans += ss; c[j] = 0; break; } else { ss += c[j]; } } if (s[i] > 0) ans++; } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:6:2: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
    6 |  vector<int> c(n, 1);
      |  ^~~~~~
      |  std::vector
In file included from /usr/include/c++/10/vector:67,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
shoes.cpp:6:9: error: expected primary-expression before 'int'
    6 |  vector<int> c(n, 1);
      |         ^~~
shoes.cpp:8:7: error: 'c' was not declared in this scope
    8 |   if (c[i] == 0) continue;
      |       ^
shoes.cpp:13:5: error: 'c' was not declared in this scope
   13 |     c[j] = 0;
      |     ^
shoes.cpp:16:11: error: 'c' was not declared in this scope
   16 |     ss += c[j];
      |           ^