답안 #949382

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
949382 2024-03-19T07:39:24 Z vjudge1 벽 칠하기 (APIO20_paint) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "paint.h"
//#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
int minimumInstructions(int N, int M, int K,vector<int> C,vector<int> A, vector<vector<int>> B) {
    for(int i=0;i<M;i++){
        sort(all(B[i]));
    }
    int ans=0;
    vector <int> used(N);
    for(int i=0;i<N;i++){
        if(!used[i] && i+M-1<N){
            
            for(int y=i;y>=max(0ll,i-M+1);y--){
                bool ok=0;
                for(int x=0;x<M;x++){
                    int cnt=0;
                    for(int l=0;l<M;l++){
                        int pos=(x+l)%M;
                        auto it=lower_bound(all(B[pos]),C[y+l]);
                        if(it!=B[pos].end() && *it==C[y+l])cnt++;
                        else break;
                    }
                    if(cnt==M)ok=1;
                }
                if(ok){
                   
                    for(int j=y;j<y+M;j++)used[j]=1;
                    ans++;
                    break;
                }
            }
        }
        
    }
    if(ans==0)ans=-1;
    return ans;
}

/*signed main(){
    ios_base::sync_with_stdio();
    cin.tie(0);cout.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    vector <int> c(n),a(m);
    for(int i=0;i<n;i++)cin>>c[i];
    for(int i=0;i<m;i++)cin>>a[i];
    vector <vector <int> > b(m);
    for(int i=0;i<m;i++){
        for(int j=0;j<a[i];j++){
            int x;
            cin>>x;
            b[i].pb(x);
        }
    }
    cout<<minimumInstructions(n,m,k,c,a,b)<<"\n";
}*/
/*
 8 3 5
 3 3 1 3 4 4 2 2
 3 2 2
 0 1 2
 2 3
 3 4
 
 
 5 4 4
 1 0 1 2 2
 2 1 1 1
 0 1
 1
 2
 3
 */

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:18:41: error: no matching function for call to 'max(long long int, int)'
   18 |             for(int y=i;y>=max(0ll,i-M+1);y--){
      |                                         ^
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: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:
paint.cpp:18:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |             for(int y=i;y>=max(0ll,i-M+1);y--){
      |                                         ^
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: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:
paint.cpp:18:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |             for(int y=i;y>=max(0ll,i-M+1);y--){
      |                                         ^
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: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:
paint.cpp:18:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |             for(int y=i;y>=max(0ll,i-M+1);y--){
      |                                         ^
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: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:
paint.cpp:18:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |             for(int y=i;y>=max(0ll,i-M+1);y--){
      |                                         ^