답안 #733221

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
733221 2023-04-30T09:22:33 Z bin9638 벽 칠하기 (APIO20_paint) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

#ifndef SKY
#include "paint.h"
#endif // SKY

using namespace std;

#define N 100010
#define ll long long
#define fs first
#define sc second
#define ii pair<int,int>
#define pb push_back

unordered_map<int,int_fast16_t>mp[N];
int n,m,k,color[N],dp[N];

int minimumInstructions(int NNN, int MMM, int KKK, vector<int> CCC,vector<int> AAA, vector<vector<int>> BBB)
{
    vector<int_fast16_t>lis[N];
    n=NNN;
    m=MMM;
    k=KKK;
    for(int i=0;i<n;i++)
        color[i]=CCC[i];
    for(int i=0;i<m;i++)
        for(auto u:BBB[i])
            lis[u].pb(i);
    if(m==1)
    {
        for(int i=0;i<n;i++)
            if(lis[color[i]].empty())
                return -1;
        return n;
    }
    for(int i=n-1;i>=0;i--)
    {
        for(auto u:lis[color[i]])
            if(mp[i+1].find((u+1)%m)!=mp[i+1].end())
                mp[i][u]=min(m,mp[i+1][(u+1)%m]+1);
                    else mp[i][u]=1;
        for(auto u:lis[color[i]])
            if(mp[i][u]==m)
                dp[i]=1;
    }
    if(dp[0]==0)
        return -1;
    int vt=0,res=0,x=0;
    while(vt<n)
    {
        if(x+m-1<vt)
            return -1;
        int new_vt=x+m;
        for(int i=vt+1;i<=new_vt;i++)
            if(dp[i]==1)
                x=max(x,i);
        vt=new_vt;
        res++;
    }
    return res;
}

#ifdef SKY
int main()
{
    freopen("A.inp","r",stdin);
    freopen("A.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m,k;
    cin>>n>>m>>k;
    vector<int>C(n);
    for(int i=0;i<n;i++)
        cin>>C[i];
    vector<int>A(m);
    vector<vector<int>>B(m);
    for(int i=0;i<m;i++)
    {
        cin>>A[i];
        B[i].resize(A[i]);
    }
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<A[i];j++)
            cin>>B[i][j];
    }
    cout<<minimumInstructions(n,m,k,C,A,B);
    return 0;
}
#endif

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:41:50: error: no matching function for call to 'min(int&, std::unordered_map<int, long int>::mapped_type)'
   41 |                 mp[i][u]=min(m,mp[i+1][(u+1)%m]+1);
      |                                                  ^
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 paint.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:
paint.cpp:41:50: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::unordered_map<int, long int>::mapped_type' {aka 'long int'})
   41 |                 mp[i][u]=min(m,mp[i+1][(u+1)%m]+1);
      |                                                  ^
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 paint.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:
paint.cpp:41:50: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::unordered_map<int, long int>::mapped_type' {aka 'long int'})
   41 |                 mp[i][u]=min(m,mp[i+1][(u+1)%m]+1);
      |                                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from paint.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:
paint.cpp:41:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   41 |                 mp[i][u]=min(m,mp[i+1][(u+1)%m]+1);
      |                                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from paint.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:
paint.cpp:41:50: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   41 |                 mp[i][u]=min(m,mp[i+1][(u+1)%m]+1);
      |                                                  ^