Submission #1317445

#TimeUsernameProblemLanguageResultExecution timeMemory
1317445nambanana987Dango Maker (JOI18_dango_maker)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include <climits> using namespace std; #define f first #define s second #define all(a) a.begin(),a.end() #define sz(a) (int)a.size() const int N=3e3+5; char M[N][N]; bool hang[N][N],cot[N][N]; string need="&RGW"; int n,m; int dp[N][N][4]; int f(int i,int j,int k){ if(i<1 || i>n || j<1 || j>m) return 0; int &res=dp[i][j][k]; if(res!=-1) return res; res=0; if(cot[i][j]==0 && k==0){ res=max(res,f(i-1,j+1,0ll)+1); } if(hang[i][j]==0){ res=max(res,f(i-1,j+1,2ll)+1); } res=max(res,f(i-1,j+1,max(0ll,k-1))); return res; } void solve(){ cin>>n>>m; for(int i=1;i<=n;++i) { for(int j=1;j<=m;++j) cin>>M[i][j]; } for(int i=1;i<=n;++i){ for(int j=1;j<=m;++j){ for(int k=1;k<=3;++k){ if(i+k-1 > n || M[i+k-1][j]!=need[k]) cot[i][j]=1; if(j+k-1 > m || M[i][j+k-1]!=need[k]) hang[i][j]=1; } } } int ans=0; memset(dp,-1,sizeof(dp)); for(int i=1;i<=n;++i) ans+=f(i,1,0); for(int i=2;i<=m;++i) ans+=f(n,i,0); cout<<ans; } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); int T=1; while(T--) solve(); }

Compilation message (stderr)

dango_maker.cpp: In function 'int first(int, int, int)':
dango_maker.cpp:29:30: error: no matching function for call to 'max(long long int, int)'
   29 |     res=max(res,f(i-1,j+1,max(0ll,k-1)));
      |                           ~~~^~~~~~~~~
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from dango_maker.cpp:1:
/usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
dango_maker.cpp:29:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   29 |     res=max(res,f(i-1,j+1,max(0ll,k-1)));
      |                           ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algobase.h:303:5: note:   template argument deduction/substitution failed:
dango_maker.cpp:29:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   29 |     res=max(res,f(i-1,j+1,max(0ll,k-1)));
      |                           ~~~^~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5795 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5795:5: note:   template argument deduction/substitution failed:
dango_maker.cpp:29:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |     res=max(res,f(i-1,j+1,max(0ll,k-1)));
      |                           ~~~^~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   template argument deduction/substitution failed:
dango_maker.cpp:29:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |     res=max(res,f(i-1,j+1,max(0ll,k-1)));
      |                           ~~~^~~~~~~~~