답안 #79466

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
79466 2018-10-14T05:34:34 Z tmwilliamlin168 Sailing Race (CEOI12_race) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int mxN=500;
int n, ai, dp1[mxN][mxN][2], dp2[mxN][mxN], dp3[mxN][mxN][2];
bool k, adj[mxN][mxN];
array<int, 2> ans;

void c(int l, int r, int a) {
	int d=a?1:-1;
	if(adj[l][r]) {
		dp1[l][r][a]=1;
		dp2[l][r][a]=1+dp3[r][(l+d+n)%n][a^1];
	} else
		dp1[l][r][a]=dp2[l][r][a]=-n;
	for(int k=(l+d+n)%n; k!=r; k=(k+d+n)%n) {
		dp1[l][r][a]=max(dp1[l][k][a]+dp1[k][r][a], dp1[l][r][a]);
		dp2[l][r][a]=max(dp1[l][k][a]+dp2[k][r][a], dp1[l][r][a]);
	}
	dp3[l][r][a]=max(dp[l][r][a][1], dp3[l][(r-d+n)%n][a]);
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i=0; i<n; ++i) {
		cin >> ai;
		while(ai) {
			adj[i][ai-1]=1;
			cin >> ai;
		}
	}
	for(int l=1; l<n; ++l) {
		for(int i=0; i<n; ++i) {
			c(i, (i+l)%n, 1);
			c((i+l)%n, i, 0);
		}
	}
	for(int i=0; i<n; ++i)
		for(int j=0; j<n; ++j)
			for(int k=0; k<2; ++k)
				ans=max({{dp2[i][j][k], i}, ans});
	if(k) {
		for(int i=0; i<n; ++i) {
			for(int j=0; j<n; ++j) {
				for(int a=0, d=-1; a<2; ++a, d=-d) {
					if(dp1[i][j][a]<=0)
						continue;
					int k=(j+d+n)%n;
					for(; k!=i&&!adj[k][i]; k=(k+d+n)%n);
					if(k!=i)
						for(int l=(k+d+n)%n; l!=i; l=(l+d+n)%n)
							if(adj[j][l])
								ans=max({{2+dp1[i][j][a]+max(dp3[l][(k+d+n)%n][a^1], dp3[l][(i-d+n)%n][a]), k}, ans});
				}
			}
		}
	}
	cout << ans[0] << "\n" << ans[1]+1;
}

Compilation message

race.cpp: In function 'void c(int, int, int)':
race.cpp:13:14: error: invalid types 'int[int]' for array subscript
   dp2[l][r][a]=1+dp3[r][(l+d+n)%n][a^1];
              ^
race.cpp:15:27: error: invalid types 'int[int]' for array subscript
   dp1[l][r][a]=dp2[l][r][a]=-n;
                           ^
race.cpp:18:14: error: invalid types 'int[int]' for array subscript
   dp2[l][r][a]=max(dp1[l][k][a]+dp2[k][r][a], dp1[l][r][a]);
              ^
race.cpp:18:44: error: invalid types 'int[int]' for array subscript
   dp2[l][r][a]=max(dp1[l][k][a]+dp2[k][r][a], dp1[l][r][a]);
                                            ^
race.cpp:20:19: error: 'dp' was not declared in this scope
  dp3[l][r][a]=max(dp[l][r][a][1], dp3[l][(r-d+n)%n][a]);
                   ^~
race.cpp:20:19: note: suggested alternative: 'd'
  dp3[l][r][a]=max(dp[l][r][a][1], dp3[l][(r-d+n)%n][a]);
                   ^~
                   d
race.cpp: In function 'int main()':
race.cpp:44:26: error: invalid types 'int[int]' for array subscript
     ans=max({{dp2[i][j][k], i}, ans});
                          ^
race.cpp:44:37: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
     ans=max({{dp2[i][j][k], i}, ans});
                                     ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from race.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
race.cpp:44:37: note:   candidate expects 2 arguments, 1 provided
     ans=max({{dp2[i][j][k], i}, ans});
                                     ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from race.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
race.cpp:44:37: note:   candidate expects 3 arguments, 1 provided
     ans=max({{dp2[i][j][k], i}, ans});
                                     ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from race.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: constexpr _Tp std::max(std::initializer_list<_Tp>) [with _Tp = std::array<int, 2>]
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<std::array<int, 2> >'
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
race.cpp:44:37: note:   candidate expects 2 arguments, 1 provided
     ans=max({{dp2[i][j][k], i}, ans});
                                     ^