답안 #386898

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
386898 2021-04-07T15:43:02 Z FatihSolak Nuclearia (CEOI15_nuclearia) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

void solve(){
    bool swp = 0;
    long long w,h;
    cin >> w >> h;
    if(w < h){
        swp = 1;
        swap(w,h);
    }
    long long arr[h+5][h+w+5];
    long long pre[h+5][h+w+5];
    for(long long i=0;i<h+5;i++){
        for(long long j = 0;j<h+w+5;j++){
            arr[i][j] = pre[i][j] = 0;
        }
    }    
    long long n;
    cin >> n;
    for(long long i=0;i<n;i++){
        long long x,y,a,b;
        cin >> x >> y >> a >> b;
        if(swp)swap(x,y);
        x += h;
        for(long long i=1;i<=h;i++){
            long long dif = abs(y-i);
            if(dif * b > a)continue;

            arr[i][max(1,x-dif+1)] -= b;
            arr[i][max(1,x-(a/b)+1)] += b;
            arr[i][max(1,x-(a/b))] += a - b*(x - max(1,x-(a/b)));
            arr[i][max(1,x-(a/b)) + 1] -= a - b*(x - max(1,x-(a/b)));

            arr[i][min(w+h+1,x+dif+1)] -= b;
            arr[i][min(w+h+1,x+(a/b)+1)] += b;
            arr[i][min(w+h+1,x+(a/b)+1)] -= a%b;
        }
    }
    for(long long i=1;i<=h;i++){
        for(long long j=1;j<=w+h;j++){
            arr[i][j] += arr[i][j-1];
        }
    }
    for(long long i=1;i<=h;i++){
        for(long long j=1;j<=w+h;j++){
            arr[i][j] += arr[i][j-1];
        }
    }
    for(long long i=1;i<=h;i++){
        for(long long j=h+1;j<=w+h;j++){
            pre[i][j] = pre[i-1][j] + pre[i][j-1] - pre[i-1][j-1]+arr[i][j];
            //cout << pre[i][j] << " "; 
        }
        //cout << endl;
    }
    /*
    for(long long i=1;i<=h;i++){
        for(long long j=h+1;j<=w+h;j++){
            cout << arr[i][j] << " ";
        }
        cout << endl;
    }*/
    long long q;
    cin >> q;
    while(q--){
        long long x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if(!swp)swap(x1,y1),swap(x2,y2);
        y1 += h;
        y2 += h;
        long double cnt = (x2-x1+1) * (y2 -y1+1);
        cout <<(long long) ((pre[x2][y2] - pre[x2][y1-1] - pre[x1 -1][y2] + pre[x1-1][y1-1])/cnt + 0.5) << endl;
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifdef Local
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    #ifdef Local
    cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Compilation message

nuclearia.cpp: In function 'void solve()':
nuclearia.cpp:30:33: error: no matching function for call to 'max(int, long long int)'
   30 |             arr[i][max(1,x-dif+1)] -= b;
      |                                 ^
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:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:30:33: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   30 |             arr[i][max(1,x-dif+1)] -= b;
      |                                 ^
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:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:30:33: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   30 |             arr[i][max(1,x-dif+1)] -= b;
      |                                 ^
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:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:30:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   30 |             arr[i][max(1,x-dif+1)] -= b;
      |                                 ^
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:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:30:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   30 |             arr[i][max(1,x-dif+1)] -= b;
      |                                 ^
nuclearia.cpp:31:35: error: no matching function for call to 'max(int, long long int)'
   31 |             arr[i][max(1,x-(a/b)+1)] += b;
      |                                   ^
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:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:31:35: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   31 |             arr[i][max(1,x-(a/b)+1)] += b;
      |                                   ^
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:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:31:35: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   31 |             arr[i][max(1,x-(a/b)+1)] += b;
      |                                   ^
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:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:31:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   31 |             arr[i][max(1,x-(a/b)+1)] += b;
      |                                   ^
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:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:31:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   31 |             arr[i][max(1,x-(a/b)+1)] += b;
      |                                   ^
nuclearia.cpp:32:33: error: no matching function for call to 'max(int, long long int)'
   32 |             arr[i][max(1,x-(a/b))] += a - b*(x - max(1,x-(a/b)));
      |                                 ^
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:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:32:33: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   32 |             arr[i][max(1,x-(a/b))] += a - b*(x - max(1,x-(a/b)));
      |                                 ^
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:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:32:33: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   32 |             arr[i][max(1,x-(a/b))] += a - b*(x - max(1,x-(a/b)));
      |                                 ^
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:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:32:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   32 |             arr[i][max(1,x-(a/b))] += a - b*(x - max(1,x-(a/b)));
      |                                 ^
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:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:32:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   32 |             arr[i][max(1,x-(a/b))] += a - b*(x - max(1,x-(a/b)));
      |                                 ^
nuclearia.cpp:32:63: error: no matching function for call to 'max(int, long long int)'
   32 |             arr[i][max(1,x-(a/b))] += a - b*(x - max(1,x-(a/b)));
      |                                                               ^
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:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:32:63: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   32 |             arr[i][max(1,x-(a/b))] += a - b*(x - max(1,x-(a/b)));
      |                                                               ^
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:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:32:63: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   32 |             arr[i][max(1,x-(a/b))] += a - b*(x - max(1,x-(a/b)));
      |                                                               ^
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:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:32:63: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   32 |             arr[i][max(1,x-(a/b))] += a - b*(x - max(1,x-(a/b)));
      |                                                               ^
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:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:32:63: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   32 |             arr[i][max(1,x-(a/b))] += a - b*(x - max(1,x-(a/b)));
      |                                                               ^
nuclearia.cpp:33:33: error: no matching function for call to 'max(int, long long int)'
   33 |             arr[i][max(1,x-(a/b)) + 1] -= a - b*(x - max(1,x-(a/b)));
      |                                 ^
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:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:33:33: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   33 |             arr[i][max(1,x-(a/b)) + 1] -= a - b*(x - max(1,x-(a/b)));
      |                                 ^
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:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:33:33: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   33 |             arr[i][max(1,x-(a/b)) + 1] -= a - b*(x - max(1,x-(a/b)));
      |                                 ^
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:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:33:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   33 |             arr[i][max(1,x-(a/b)) + 1] -= a - b*(x - max(1,x-(a/b)));
      |                                 ^
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:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:33:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   33 |             arr[i][max(1,x-(a/b)) + 1] -= a - b*(x - max(1,x-(a/b)));
      |                                 ^
nuclearia.cpp:33:67: error: no matching function for call to 'max(int, long long int)'
   33 |             arr[i][max(1,x-(a/b)) + 1] -= a - b*(x - max(1,x-(a/b)));
      |                                                                   ^
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:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:33:67: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   33 |             arr[i][max(1,x-(a/b)) + 1] -= a - b*(x - max(1,x-(a/b)));
      |                                                                   ^
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:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:33:67: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   33 |             arr[i][max(1,x-(a/b)) + 1] -= a - b*(x - max(1,x-(a/b)));
      |                                                                   ^
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:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
nuclearia.cpp:33:67: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   33 |             arr[i][max(1,x-(a/b)) + 1] -= a - b*(x - max(1,x-(a/b)));
      |                                                                   ^
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:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp