제출 #1137313

#제출 시각아이디문제언어결과실행 시간메모리
1137313viwlesxq선물상자 (IOI15_boxes)C++20
컴파일 에러
0 ms0 KiB
#include "boxes.h" #include <bits/stdc++.h> using namespace std; typedef long long i64; i64 delivery(int n, int k, int l, int p[]) { auto dist = [&](int x, int y) { if (x > y) swap(x, y); return min(y - x, x + n - y); }; i64 res = 0; deque<int> q; for (int i = 0; i < n; ++i) { q.push_back(p[i]); } int pos = 0; while (!p.empty()) { if (dist(pos, p.front()) < dist(pos, p.back())) { res += dist(pos, p.front()); pos = p.front(); p.pop_front(); } else { res += dist(pos, p.back()); pos = p.back(); p.pop_back(); } } res += dist(pos, 0); return res; }

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

boxes.cpp: In function 'i64 delivery(int, int, int, int*)':
boxes.cpp:23:15: error: request for member 'empty' in 'p', which is of non-class type 'int*'
   23 |     while (!p.empty()) {
      |               ^~~~~
boxes.cpp:24:25: error: request for member 'front' in 'p', which is of non-class type 'int*'
   24 |         if (dist(pos, p.front()) < dist(pos, p.back())) {
      |                         ^~~~~
boxes.cpp:24:48: error: request for member 'back' in 'p', which is of non-class type 'int*'
   24 |         if (dist(pos, p.front()) < dist(pos, p.back())) {
      |                                                ^~~~
boxes.cpp:25:32: error: request for member 'front' in 'p', which is of non-class type 'int*'
   25 |             res += dist(pos, p.front());
      |                                ^~~~~
boxes.cpp:26:21: error: request for member 'front' in 'p', which is of non-class type 'int*'
   26 |             pos = p.front();
      |                     ^~~~~
boxes.cpp:27:15: error: request for member 'pop_front' in 'p', which is of non-class type 'int*'
   27 |             p.pop_front();
      |               ^~~~~~~~~
boxes.cpp:29:32: error: request for member 'back' in 'p', which is of non-class type 'int*'
   29 |             res += dist(pos, p.back());
      |                                ^~~~
boxes.cpp:30:21: error: request for member 'back' in 'p', which is of non-class type 'int*'
   30 |             pos = p.back();
      |                     ^~~~
boxes.cpp:31:15: error: request for member 'pop_back' in 'p', which is of non-class type 'int*'
   31 |             p.pop_back();
      |               ^~~~~~~~