제출 #1068905

#제출 시각아이디문제언어결과실행 시간메모리
1068905epicci23Dango Maker (JOI18_dango_maker)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" #define all(v) v.begin() , v.end() using namespace std; const int INF = 1e9; const int N = 3005; int dp[N][N][2],ans[N][N]; void _(){ int n,m,ans=0; cin >> n >> m; vector<string> v; v.push_back("$"); for(int i=0;i<n;i++){ string s;cin >> s; s="$"+s; v.push_back(s); } for(int i=1;i<=n;i++){ for(int j=m;j>=1;j--){ bool ok0=0,ok1=0; if(i+2<=n && v[i][j]=='R' && v[i+1][j]=='G' && v[i+2][j]=='W') ok0=1; if(j+2<=m && v[i][j]=='R' && v[i][j+1]=='G' && v[i][j+2]=='W') ok1=1; dp[i][j][0]=dp[i][j][1]=-INF; if(ok0){ dp[i][j][0]=1; if(i-1>=1 && j+1<=m) dp[i][j][0]=max(dp[i][j][0],ans[i-1][j+1]+1); } else dp[i][j][0]=-INF; if(ok1){ dp[i][j][1]=1; if(i-1>=1 && j+1<=m) dp[i][j][1]=max(dp[i][j][1],dp[i-1][j+1][1]+1); if(i-2>=1 && j+2<=m) dp[i][j][1]=max(dp[i][j][1],dp[i-2][j+2][1]+1); if(i-3>=1 && j+3<=m) dp[i][j][1]=max(dp[i][j][1],ans[i-3][j+3]+1); } else dp[i][j][1]=-INF; ans[i][j]=max({ans[i-1][j+1],dp[i][j][0],dp[i][j][1]}); } } for(int i=1;i<=n;i++) ans+=ans[i][1]; cout << ans << '\n'; } int32_t main(){ cin.tie(0); ios::sync_with_stdio(0); int tc=1;//cin >> tc; while(tc--) _(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

dango_maker.cpp: In function 'void _()':
dango_maker.cpp:26:61: error: invalid types 'int[int]' for array subscript
   26 |         if(i-1>=1 && j+1<=m) dp[i][j][0]=max(dp[i][j][0],ans[i-1][j+1]+1);
      |                                                             ^
dango_maker.cpp:33:61: error: invalid types 'int[int]' for array subscript
   33 |         if(i-3>=1 && j+3<=m) dp[i][j][1]=max(dp[i][j][1],ans[i-3][j+3]+1);
      |                                                             ^
dango_maker.cpp:36:10: error: invalid types 'int[int]' for array subscript
   36 |       ans[i][j]=max({ans[i-1][j+1],dp[i][j][0],dp[i][j][1]});
      |          ^
dango_maker.cpp:36:25: error: invalid types 'int[int]' for array subscript
   36 |       ans[i][j]=max({ans[i-1][j+1],dp[i][j][0],dp[i][j][1]});
      |                         ^
dango_maker.cpp:36:60: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   36 |       ans[i][j]=max({ans[i-1][j+1],dp[i][j][0],dp[i][j][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 dango_maker.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:
dango_maker.cpp:36:60: note:   candidate expects 2 arguments, 1 provided
   36 |       ans[i][j]=max({ans[i-1][j+1],dp[i][j][0],dp[i][j][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 dango_maker.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:
dango_maker.cpp:36:60: note:   candidate expects 3 arguments, 1 provided
   36 |       ans[i][j]=max({ans[i-1][j+1],dp[i][j][0],dp[i][j][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 dango_maker.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:
/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:
dango_maker.cpp:39:33: error: invalid types 'int[int]' for array subscript
   39 |   for(int i=1;i<=n;i++) ans+=ans[i][1];
      |                                 ^