Submission #898278

#TimeUsernameProblemLanguageResultExecution timeMemory
898278marcidChessboard (IZhO18_chessboard)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long struct rect { ll x1, y1, x2, y2; }; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); vector<rect> a; ll n, k; cin >> n >> k; for (int i = 0; i < k; i++) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; a.push_back({x1, y1, x2, y2}); } ll res = n * n; ll wh_cnt[n + 1], bl_cnt[n + 1]; for (int d = 1; d < n; d++) { if (n % d) continue; wh_cnt[0] = 0; bl_cnt[0] = 0; for (int i = 1; i <= n; i++) { int id = (i + d - 1) / d; wh_cnt[i] = wh_cnt[i - 1]; bl_cnt[i] = bl_cnt[i - 1]; if (id % 2) { wh_cnt[i]++; } else { bl_cnt[i]++; } } ll cur = (n / d) * (n / d) / 2 * d * d; for (auto [x1, y1, x2, y2] : a) { cur += (wh_cnt[x2] - wh_cnt[x1 - 1]) * (wh_cnt[y2] - wh_cnt[y1 - 1]) + (bl_cnt[x2] - bl_cnt[x1 - 1]) * (bl_cnt[y2] - bl_cnt[y1 - 1]); cur -= (wh_cnt[x2] - wh_cnt[x1 - 1]) * (bl_cnt[y2] - bl_cnt[y1 - 1]) + (bl_cnt[x2] - bl_cnt[x1 - 1]) * (wh_cnt[y2] - wh_cnt[y1 - 1]); } res = min({res, cur, n * n - cur}); } cout << res << '\n'; return 0; }

Compilation message (stderr)

chessboard.cpp:5:5: error: 'll' does not name a type
    5 |     ll x1, y1, x2, y2;
      |     ^~
chessboard.cpp: In function 'int main()':
chessboard.cpp:13:5: error: 'll' was not declared in this scope
   13 |     ll n, k;
      |     ^~
chessboard.cpp:14:12: error: 'n' was not declared in this scope
   14 |     cin >> n >> k;
      |            ^
chessboard.cpp:14:17: error: 'k' was not declared in this scope
   14 |     cin >> n >> k;
      |                 ^
chessboard.cpp:18:37: error: no matching function for call to 'std::vector<rect>::push_back(<brace-enclosed initializer list>)'
   18 |         a.push_back({x1, y1, x2, y2});
      |                                     ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from chessboard.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = rect; _Alloc = std::allocator<rect>; std::vector<_Tp, _Alloc>::value_type = rect]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const rect&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = rect; _Alloc = std::allocator<rect>; std::vector<_Tp, _Alloc>::value_type = rect]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<rect>::value_type&&' {aka 'rect&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
chessboard.cpp:21:7: error: expected ';' before 'res'
   21 |     ll res = n * n;
      |       ^~~~
      |       ;
chessboard.cpp:22:7: error: expected ';' before 'wh_cnt'
   22 |     ll wh_cnt[n + 1], bl_cnt[n + 1];
      |       ^~~~~~~
      |       ;
chessboard.cpp:26:9: error: 'wh_cnt' was not declared in this scope
   26 |         wh_cnt[0] = 0;
      |         ^~~~~~
chessboard.cpp:27:9: error: 'bl_cnt' was not declared in this scope; did you mean 'blkcnt_t'?
   27 |         bl_cnt[0] = 0;
      |         ^~~~~~
      |         blkcnt_t
chessboard.cpp:39:11: error: expected ';' before 'cur'
   39 |         ll cur = (n / d) * (n / d) / 2 * d * d;
      |           ^~~~
      |           ;
chessboard.cpp:40:19: error: cannot decompose class type 'rect' without non-static data members
   40 |         for (auto [x1, y1, x2, y2] : a) {
      |                   ^~~~~~~~~~~~~~~~
chessboard.cpp:41:13: error: 'cur' was not declared in this scope
   41 |             cur += (wh_cnt[x2] - wh_cnt[x1 - 1]) * (wh_cnt[y2] - wh_cnt[y1 - 1]) + (bl_cnt[x2] - bl_cnt[x1 - 1]) * (bl_cnt[y2] - bl_cnt[y1 - 1]);
      |             ^~~
chessboard.cpp:44:9: error: 'res' was not declared in this scope
   44 |         res = min({res, cur, n * n - cur});
      |         ^~~
chessboard.cpp:44:25: error: 'cur' was not declared in this scope
   44 |         res = min({res, cur, n * n - cur});
      |                         ^~~
chessboard.cpp:44:42: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   44 |         res = min({res, cur, n * n - cur});
      |                                          ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from chessboard.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
chessboard.cpp:44:42: note:   candidate expects 2 arguments, 1 provided
   44 |         res = min({res, cur, n * n - cur});
      |                                          ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from chessboard.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
chessboard.cpp:44:42: note:   candidate expects 3 arguments, 1 provided
   44 |         res = min({res, cur, n * n - cur});
      |                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from chessboard.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
chessboard.cpp:47:13: error: 'res' was not declared in this scope
   47 |     cout << res << '\n';
      |             ^~~