Submission #365887

#TimeUsernameProblemLanguageResultExecution timeMemory
365887kostia244Nuclearia (CEOI15_nuclearia)C++17
Compilation error
0 ms0 KiB
#pragma GCC optimize("trapv,unroll-loops") #pragma GCC target("avx,avx2,sse,sse2") #include<bits/stdc++.h> #define all(x) begin(x), end(x) using namespace std; using ll = long long; int n, m, q; vector<vector<ll>> che; vector<ll> rur, rul; void init() { che.resize(n, vector<ll>(m)); rur.resize(m); rul.resize(m); } void add_radius(int x, int y, int r, ll val) { che[max(x-r, 0)][max(y-r, 0)] += val; if(x+r+1 < n) che[x+r+1][max(y-r, 0)] -= val; if(y+r+1 < m) che[max(x-r, 0)][y+r+1] -= val; if(x+r+1 < n && y+r+1 < m) che[x+r+1][y+r+1] += val; } void add_vert(int x, int y, ll a, ll b) { ll maxrad = a/b; add_radius(x, y, maxrad, a - b*maxrad); //cout << a-b*maxrad << ":((" << endl; for(int i = 0; i < min(max(n, m), maxrad); i++) { add_radius(x, y, i, b); } } void finish() { for(int it = 0; it < 2; it++) { for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(i) che[i][j] += che[i-1][j]; if(j) che[i][j] += che[i][j-1]; if(i&&j) che[i][j] -= che[i-1][j-1]; } } /* for(auto i : che) { for(auto j : i) cout << j << " "; cout << endl; }*/ } } ll get_rect(int xl, int xr, int yl, int yr) { ll sum = che[xr][yr]; --xl, --yl; if(xl>=0) sum -= che[xl][yr]; if(yl>=0) sum -= che[xr][yl]; if(xl>=0&&yl>=0) sum += che[xl][yl]; ll area = (xr-xl)*(yr-yl); //cout << xl << " " << xr << " " << yl << " " << yr << " " << area << endl; ll rem = sum % area; return (sum/area) + (rem*2 >= area); } int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> m >> q; int rev = 0; if(n > m) swap(n, m), rev = 1; init(); for(int x, y, a, b; q--;) { cin >> x >> y >> a >> b;x--, y--; if(rev) swap(x, y); add_vert(x, y, a, b); } finish(); cin >> q; for(int xl, xr, yl, yr; q--;) { cin >> xl >> yl >> xr >> yr;xl--,xr--,yl--,yr--; if(rev) swap(xl, yl); if(rev) swap(xr, yr); //cout << xl << " " << xr << " " << yl << " " << yr << " QUERY:" << endl; cout << get_rect(xl, xr, yl, yr) << '\n'; } }

Compilation message (stderr)

nuclearia.cpp: In function 'void add_vert(int, int, ll, ll)':
nuclearia.cpp:29:42: error: no matching function for call to 'min(const int&, ll&)'
   29 |  for(int i = 0; i < min(max(n, m), maxrad); i++) {
      |                                          ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from nuclearia.cpp:3:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:29:42: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   29 |  for(int i = 0; i < min(max(n, m), maxrad); i++) {
      |                                          ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from nuclearia.cpp:3:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:29:42: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   29 |  for(int i = 0; i < min(max(n, m), maxrad); i++) {
      |                                          ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from nuclearia.cpp:3:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:29:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |  for(int i = 0; i < min(max(n, m), maxrad); i++) {
      |                                          ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from nuclearia.cpp:3:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:29:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |  for(int i = 0; i < min(max(n, m), maxrad); i++) {
      |                                          ^