Submission #78639

# Submission time Handle Problem Language Result Execution time Memory
78639 2018-10-06T18:25:34 Z ekrem Sailing Race (CEOI12_race) C++
0 / 100
346 ms 3892 KB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define inf 1000000007
#define N 505
using namespace std;

int n, d, x, ans, dp[N][N], h[N][N];
vector < int > g[N];

int f(int bas, int son){
	int &r = dp[bas][son];
	if(r != -1)
		return r;
	r = -inf;
	if(bas == son)
		return r = 0;
	if(h[bas][son])
		r = 1;
	if(bas < son)
		for(int i = bas + 1; i < son; i++)
			r = max(r, f(bas, i) + f(i, son));
	else
		for(int i = son + 1; i < bas; i++)
			r = max(r, f(bas, i) + f(i, son));
	return r;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);

	memset(dp, -1, sizeof dp);

	scanf("%d %d",&n ,&d);
	for(int i = 1; i <= n; i++){
		while(1){
			scanf("%d",&x);
			if(!x)
				break;
			g[i].pb(x);
			h[i][x] = 1;
		}
	}
	for(int i = 1; i <= n; i++)
		for(int j = 0; j < g[i].size(); j++){
			for(int k = 1; k <= n; k++)
				if(k != i)
					ans = max(ans, f(g[i][j], k) + 1);
				// printf("dp[%d][%d] = %d\n", g[i][j], k, f(g[i][j], k));}
		}
	printf("%d\n", ans);
	return 0;
}

Compilation message

race.cpp: In function 'int main()':
race.cpp:48:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j < g[i].size(); j++){
                  ~~^~~~~~~~~~~~~
race.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n ,&d);
  ~~~~~^~~~~~~~~~~~~~~~
race.cpp:40:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&x);
    ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1400 KB Unexpected end of file - int32 expected
2 Incorrect 3 ms 1536 KB Output isn't correct
3 Incorrect 3 ms 1536 KB Output isn't correct
4 Incorrect 3 ms 1536 KB Output isn't correct
5 Incorrect 3 ms 1536 KB Output isn't correct
6 Incorrect 4 ms 1676 KB Output isn't correct
7 Incorrect 7 ms 1740 KB Output isn't correct
8 Incorrect 4 ms 1760 KB Output isn't correct
9 Incorrect 5 ms 1784 KB Output isn't correct
10 Incorrect 9 ms 1924 KB Output isn't correct
11 Incorrect 7 ms 1924 KB Output isn't correct
12 Incorrect 28 ms 2228 KB Output isn't correct
13 Incorrect 58 ms 2408 KB Output isn't correct
14 Incorrect 134 ms 2552 KB Output isn't correct
15 Incorrect 264 ms 2984 KB Output isn't correct
16 Incorrect 286 ms 3360 KB Output isn't correct
17 Incorrect 262 ms 3364 KB Output isn't correct
18 Incorrect 237 ms 3364 KB Output isn't correct
19 Incorrect 296 ms 3724 KB Output isn't correct
20 Incorrect 346 ms 3892 KB Output isn't correct