Submission #412827

#TimeUsernameProblemLanguageResultExecution timeMemory
412827MasterTasterparentrises (BOI18_parentrises)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back #define ll long long #define pii pair<int, int> #define xx first #define yy second #define MAXN 1006 using namespace std; int n, a[MAXN]; bool dp[MAXN][505][505]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int p; cin>>p; if (p==1) { int t; cin>>t; while (t--) { vector<char> ress; string s; cin>>s; n=s.size(); for (int i=0; i<n; i++) if (s[i]=='(') a[i]=1; else a[i]=-1; for (int i=0; i<n; i++) for (int j=0; j<n; j++) for (int k=0; k<n; k++) dp[i][j][k]=0; ///prvi-R, G ///drugi-B, G if (a[0]==-1) { cout<<"impossible"<<endl; continue; } if (a[n-1]==1) { cout<<"impossible"<<endl; continue; } dp[0][1][0]=1; dp[0][1][1]=1; dp[0][0][1]=1; bool imp=false; for (int i=1; i<n; i++) { for (int j=0; j<((n+1)/2); j++) { for (int k=0; k<((n+1)/2); k++) { //cout<<dp[i][j][k]<<" "<<a[i]<<endl; ///ako bojim u R if (j-a[i]>=0 && j-a[i]<((n+1)/2)) dp[i][j][k]=max(dp[i][j][k], dp[i-1][j-a[i]][k]); ///ako bojim u B if (k-a[i]>=0 && k-a[i]<((n+1)/2)) dp[i][j][k]=max(dp[i][j][k], dp[i-1][j][k-a[i]]); ///ako bojim u G if (j-a[i]>=0 && j-a[i]<((n+1)/2) && k-a[i]>=0 && k-a[i]<((n+1)/2)) dp[i][j][k]=max(dp[i][j][k], dp[i-1][j-a[i]][k-a[i]]); //cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<endl; } } int maxx=0; for (int j=0; j<((n+1)/2); j++) for (int k=0; k<((n+1)/2); k++) maxx=max(maxx, dp[i][j][k]); if (maxx==0) { cout<<"impossible"<<endl; imp=true; break; } } if (imp) continue; if (dp[n-1][0][0]==0) { cout<<"impossible"<<endl; continue; } int i=n-1, j=0, k=0; while (i>=0) { if (i==0) { if (j==1 && k==1) ress.pb('G'); else if (j==1) ress.pb('R'); else ress.pb('B'); break; } if (dp[i-1][j-a[i]][k]) { ress.pb('R'); j-=a[i]; } else if (dp[i-1][j][k-a[i]]) { ress.pb('B'); k-=a[i]; } else { ress.pb('G'); j-=a[i]; k-=a[i]; } i--; } reverse(ress.begin(), ress.end()); for (int i=0; i<ress.size(); i++) cout<<ress[i]; cout<<endl; } } } /* 1 3 ())(() ()(() ())) */

Compilation message (stderr)

parentrises.cpp: In function 'int main()':
parentrises.cpp:60:107: error: no matching function for call to 'max(int&, bool&)'
   60 |                 for (int j=0; j<((n+1)/2); j++) for (int k=0; k<((n+1)/2); k++) maxx=max(maxx, dp[i][j][k]);
      |                                                                                                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from parentrises.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:
parentrises.cpp:60:107: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'bool')
   60 |                 for (int j=0; j<((n+1)/2); j++) for (int k=0; k<((n+1)/2); k++) maxx=max(maxx, dp[i][j][k]);
      |                                                                                                           ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from parentrises.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:
parentrises.cpp:60:107: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'bool')
   60 |                 for (int j=0; j<((n+1)/2); j++) for (int k=0; k<((n+1)/2); k++) maxx=max(maxx, dp[i][j][k]);
      |                                                                                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from parentrises.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:
parentrises.cpp:60:107: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   60 |                 for (int j=0; j<((n+1)/2); j++) for (int k=0; k<((n+1)/2); k++) maxx=max(maxx, dp[i][j][k]);
      |                                                                                                           ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from parentrises.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:
parentrises.cpp:60:107: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   60 |                 for (int j=0; j<((n+1)/2); j++) for (int k=0; k<((n+1)/2); k++) maxx=max(maxx, dp[i][j][k]);
      |                                                                                                           ^
parentrises.cpp:77:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |             for (int i=0; i<ress.size(); i++) cout<<ress[i];
      |                           ~^~~~~~~~~~~~