제출 #1336858

#제출 시각아이디문제언어결과실행 시간메모리
1336858LIACultivation (JOI17_cultivation)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#define ll long long
#define v vector
#define lp(i, s, e) for (int i = s; i < e; ++i)
struct Point {
  ll x, y;
  bool operator<(const Point &o) const { return y < o.y; }
};

ll R_grid, C_grid;
int N;
v<Point> pts;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin >> R_grid >> C_grid >> N;

  pts.resize(N);
  lp(i, 0, N) { cin >> pts[i].x >> pts[i].y; }

  sort(pts.begin(), pts.end());

  v<ll> H_cands;
  lp(i, 0, N) {
    lp(j, 0, N) {
      ll diff = abs(pts[i].x - pts[j].x);
      H_cands.push_back(diff);
      H_cands.push_back(diff - 1);
    }
  }

  ll min_x = pts[0].x, max_x = pts[0].x;
  lp(i, 1, N) {
    min_x = min(min_x, pts[i].x);
    max_x = max(max_x, pts[i].x);
  }
  H_cands.push_back(R_grid - 1 + min_x - max_x);

  sort(H_cands.begin(), H_cands.end());
  H_cands.erase(unique(H_cands.begin(), H_cands.end()), H_cands.end());

  ll ans = 4e18;

  lp(hi, 0, H_cands.size()) {
    ll H = H_cands[hi];
    if (H < 0)
      continue;

    ll L_req = 0, R_req = 0, W_req = 0;

    bool po = true;

    if (po) {
      ll cur = max(L_req + R_req, W_req);
      ans = min(ans, H + cur);
    }
  }

  cout << ans << '\n';
  return 0;
}

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

cultivation.cpp:3:11: error: 'vector' does not name a type
    3 | #define v vector
      |           ^~~~~~
cultivation.cpp:12:1: note: in expansion of macro 'v'
   12 | v<Point> pts;
      | ^
cultivation.cpp: In function 'int main()':
cultivation.cpp:15:3: error: 'ios_base' has not been declared
   15 |   ios_base::sync_with_stdio(0);
      |   ^~~~~~~~
cultivation.cpp:16:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   16 |   cin.tie(0);
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:146,
                 from cultivation.cpp:1:
/usr/include/c++/13/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
cultivation.cpp:20:3: error: 'pts' was not declared in this scope; did you mean 'puts'?
   20 |   pts.resize(N);
      |   ^~~
      |   puts
cultivation.cpp:23:3: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   23 |   sort(pts.begin(), pts.end());
      |   ^~~~
      |   std::sort
In file included from /usr/include/c++/13/algorithm:73,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51:
/usr/include/c++/13/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
cultivation.cpp:3:11: error: 'vector' was not declared in this scope
    3 | #define v vector
      |           ^~~~~~
cultivation.cpp:25:3: note: in expansion of macro 'v'
   25 |   v<ll> H_cands;
      |   ^
cultivation.cpp:3:11: note: suggested alternatives:
    3 | #define v vector
      |           ^~~~~~
cultivation.cpp:25:3: note: in expansion of macro 'v'
   25 |   v<ll> H_cands;
      |   ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/13/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
cultivation.cpp:2:12: error: expected primary-expression before 'long'
    2 | #define ll long long
      |            ^~~~
cultivation.cpp:25:5: note: in expansion of macro 'll'
   25 |   v<ll> H_cands;
      |     ^~
cultivation.cpp:29:7: error: 'H_cands' was not declared in this scope
   29 |       H_cands.push_back(diff);
      |       ^~~~~~~
cultivation.cpp:36:13: error: 'min' was not declared in this scope; did you mean 'std::min'?
   36 |     min_x = min(min_x, pts[i].x);
      |             ^~~
      |             std::min
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: 'std::min' declared here
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
cultivation.cpp:37:5: error: 'max_x' was not declared in this scope
   37 |     max_x = max(max_x, pts[i].x);
      |     ^~~~~
cultivation.cpp:37:13: error: 'max' was not declared in this scope; did you mean 'std::max'?
   37 |     max_x = max(max_x, pts[i].x);
      |             ^~~
      |             std::max
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: 'std::max' declared here
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
cultivation.cpp:39:3: error: 'H_cands' was not declared in this scope
   39 |   H_cands.push_back(R_grid - 1 + min_x - max_x);
      |   ^~~~~~~
cultivation.cpp:39:42: error: 'max_x' was not declared in this scope
   39 |   H_cands.push_back(R_grid - 1 + min_x - max_x);
      |                                          ^~~~~
cultivation.cpp:42:17: error: 'unique' was not declared in this scope; did you mean 'std::unique'?
   42 |   H_cands.erase(unique(H_cands.begin(), H_cands.end()), H_cands.end());
      |                 ^~~~~~
      |                 std::unique
/usr/include/c++/13/pstl/glue_algorithm_defs.h:234:1: note: 'std::unique' declared here
  234 | unique(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~
cultivation.cpp:56:16: error: 'max' was not declared in this scope; did you mean 'std::max'?
   56 |       ll cur = max(L_req + R_req, W_req);
      |                ^~~
      |                std::max
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: 'std::max' declared here
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
cultivation.cpp:57:13: error: 'min' was not declared in this scope; did you mean 'std::min'?
   57 |       ans = min(ans, H + cur);
      |             ^~~
      |             std::min
/usr/include/c++/13/bits/stl_algo.h:5785:5: note: 'std::min' declared here
 5785 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
cultivation.cpp:61:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   61 |   cout << ans << '\n';
      |   ^~~~
      |   std::cout
/usr/include/c++/13/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~