답안 #1107541

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1107541 2024-11-01T12:28:16 Z Ahmed57 모자이크 (IOI24_mosaic) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int arr1[3][100001];
int arr2[100001][3];
int ans[200001];
void upd(int x,int y,int val){
    if(x<3){
        arr1[x][y] = val;
    }
    if(y<3){
        arr2[x][y] = val;
    }
}
int get(int x,int y){
    if(x<3)return arr1[x][y];
    else return arr2[x][y];
}
vector<long long> mosaic(vector<int32_t> X, vector<int32_t> Y, vector<int32_t> T, vector<int32_t> B, vector<int32_t> L, vector<int32_t> R) {
    int n = X.size();
    for(int i = 0;i<n;i++){
        for(int j = 0;j<n;j++){
            if(i==0){
                upd(i,j,X[j]);
            }else if(j==0){
                upd(i,j,Y[i]);
            }else{
                upd(i,j,(get(i-1,j)==0&&get(i,j-1)==0));
            }
            ans[i-j+n] = get(i,j);
        }
    }
    for(int i = 1;i<2*n;i++){
        ans[i]+=ans[i-1];
    }
    for(int i = 0;i<3;i++){
        for(int j = 1;j<n;j++){
            arr1[i][j]+=arr1[i][j-1];
            arr2[j][i]+=arr2[j-1][i];
        }
    }
    vector<int> ans;
    for(int i = 0;i<T.size();i++){
        int x1 = T[i] , x2 = B[i];
        int y1 = L[i] , y2 = R[i];
        long long all = 0;
        while(x1<=min(2,x2)){
            all+=arr1[x1][y2]-(y1==0?0:arr1[x1][y1-1]);
            x1++;
        }
        while(y1<=min(2,y2)){
            all+=arr2[x2][y1]-(x1==0?0:arr2[x1-1][y1]);
            y1++;
        }
        int mi = (x1-y2+n);
        int ma = (x2-y1+n);
        int lon = min(y2-y1+1,x2-x1+1);
        all+=(ans[ma]-ans[mi-1])*lon;
        ans.push_back(all);
    }
    return ans;
}

Compilation message

mosaic.cpp: In function 'std::vector<long long int> mosaic(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
mosaic.cpp:43:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for(int i = 0;i<T.size();i++){
      |                   ~^~~~~~~~~
mosaic.cpp:47:27: error: no matching function for call to 'min(int, long long int&)'
   47 |         while(x1<=min(2,x2)){
      |                           ^
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 mosaic.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:
mosaic.cpp:47:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   47 |         while(x1<=min(2,x2)){
      |                           ^
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 mosaic.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:
mosaic.cpp:47:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   47 |         while(x1<=min(2,x2)){
      |                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mosaic.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:
mosaic.cpp:47:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   47 |         while(x1<=min(2,x2)){
      |                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mosaic.cpp:1:
/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:
mosaic.cpp:47:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   47 |         while(x1<=min(2,x2)){
      |                           ^
mosaic.cpp:51:27: error: no matching function for call to 'min(int, long long int&)'
   51 |         while(y1<=min(2,y2)){
      |                           ^
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 mosaic.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:
mosaic.cpp:51:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   51 |         while(y1<=min(2,y2)){
      |                           ^
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 mosaic.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:
mosaic.cpp:51:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   51 |         while(y1<=min(2,y2)){
      |                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mosaic.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:
mosaic.cpp:51:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   51 |         while(y1<=min(2,y2)){
      |                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from mosaic.cpp:1:
/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:
mosaic.cpp:51:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   51 |         while(y1<=min(2,y2)){
      |                           ^