Submission #813214

# Submission time Handle Problem Language Result Execution time Memory
813214 2023-08-07T14:19:06 Z JakobZorz Nuclearia (CEOI15_nuclearia) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <stack>
#include <limits.h>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <cstring>
#include <sstream>
 
#pragma GCC target("popcnt")
 
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;
typedef pair<ll,ll>point;
//#define x first
//#define y second

vector<ll>map_arr;
int w,h;

void init_map(){
    map_arr.resize(w*h);
}

ll&get(int x,int y){
    return map_arr[y*w+x];
}
 
int main(){
    ios::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);
    
    cin>>w>>h;
    init_map();
    int n;
    cin>>n;
    while(n--){
        int x1,y1;
        ll center,step;
        cin>>x1>>y1>>center>>step;
        x1--;y1--;
        
        for(int x=0;x<w;x++)
            for(int y=0;y<h;y++){
                int dist=max(abs(x1-x),abs(y1-y));
                ll val=max(0,center-dist*step);
                get(x,y)+=val;
            }
    }
    
    int q;
    cin>>q;
    while(q--){
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        x1--;y1--;
        
        ll sum=0;
        for(int x=x1;x<x2;x++)
            for(int y=y1;y<y2;y++)
                sum+=get(x,y);
        ll area=(x2-x1)*(y2-y1);
        ll res=sum/area;
        if((sum%area)*2 >= area)
            res++;
        cout<<res<<"\n";
    }

    return 0;
}

/*
 
4 3
2
1 1 7 3
3 2 4 2
4
1 2 2 3
1 1 4 3
4 2 4 2
1 3 4 3
 
 */

Compilation message

nuclearia.cpp: In function 'int main()':
nuclearia.cpp:56:46: error: no matching function for call to 'max(int, ll)'
   56 |                 ll val=max(0,center-dist*step);
      |                                              ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from nuclearia.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:56:46: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   56 |                 ll val=max(0,center-dist*step);
      |                                              ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from nuclearia.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:56:46: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   56 |                 ll val=max(0,center-dist*step);
      |                                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from nuclearia.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:56:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   56 |                 ll val=max(0,center-dist*step);
      |                                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from nuclearia.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:56:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   56 |                 ll val=max(0,center-dist*step);
      |                                              ^