답안 #51560

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
51560 2018-06-18T15:41:35 Z Flying_dragon_02 The Kingdom of JOIOI (JOI17_joioi) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>

using namespace std;

const long inf = 1e9;
int n,m,pos[2005];
long a[2005][2005],ans = inf,mn = inf,mini[2005][2005],maxi[2005][2005],temp[2005][2005];

void _rotate(){
    int numi=1,numj=1;
    for(int i = 1 ; i <= m;i++){
        for(int j = n;j >= 1;j--){
            temp[numi][numj] = a[j][i];
            numj++;
        }
        numj=1;
        numi++;
    }
    swap(n,m);
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=m;j++)
            a[i][j] = temp[i][j];
    }
}

bool check(long val){
    for(int i = 1;i <= n;i++){
        pos[i] = m + 1;
        for(int j = 1;j <= m;j++){
            if(a[i][j] > mn + val){pos[i] = j; break;}
        }
    }
    for(int i = 1;i <= n;i++){
        mini[i][m+1] = inf;
        maxi[i][m+1] = 1;
        for(int j = m;j >= 1;j--){
            mini[i][j] = min(a[i][j],mini[i][j+1]);
            maxi[i][j] = max(a[i][j],maxi[i][j+1]);
        }
        mini[i][0] = mini[i][1]; maxi[i][0] = maxi[i][1];
    }
    long curMin = inf,curMax = 1,cur = m;
    for(int i = 1;i <= n;i++){
        cur = min(cur,pos[i] - 1);
        curMin = min(curMin,mini[i][cur+1]);
        curMax = max(curMax,maxi[i][cur+1]);
    }
    if(curMax - curMin<=val)
        return 1;
    else
        return 0;
}

void solve(){
    int l = 0,r = inf - 1,mid;
    while(l<r){
        mid = (l+r)/2;
        if(check(mid)) r = mid;
        else l = mid+1;
    }
    ans = min(ans,l);
}

int main(){
    cin.tie(0),ios::sync_with_stdio(0);
    cin >> n >> m;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= m;j++){
            cin >> a[i][j];
            mn = min(mn,a[i][j]);
        }
    }
    solve();
    for(int i = 1;i <= 3;i++){
        _rotate();
        solve();
    }
    cout << ans;
}

Compilation message

joioi.cpp: In function 'bool check(long int)':
joioi.cpp:44:33: error: no matching function for call to 'min(long int&, int)'
         cur = min(cur,pos[i] - 1);
                                 ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from joioi.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
joioi.cpp:44:33: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
         cur = min(cur,pos[i] - 1);
                                 ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from joioi.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
joioi.cpp:44:33: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
         cur = min(cur,pos[i] - 1);
                                 ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from joioi.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
joioi.cpp:44:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
         cur = min(cur,pos[i] - 1);
                                 ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from joioi.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
joioi.cpp:44:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
         cur = min(cur,pos[i] - 1);
                                 ^
joioi.cpp: In function 'void solve()':
joioi.cpp:61:20: error: no matching function for call to 'min(long int&, int&)'
     ans = min(ans,l);
                    ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from joioi.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
joioi.cpp:61:20: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
     ans = min(ans,l);
                    ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from joioi.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
joioi.cpp:61:20: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
     ans = min(ans,l);
                    ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from joioi.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
joioi.cpp:61:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
     ans = min(ans,l);
                    ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from joioi.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
joioi.cpp:61:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
     ans = min(ans,l);
                    ^