Submission #66340

# Submission time Handle Problem Language Result Execution time Memory
66340 2018-08-10T09:08:46 Z ikura355 Sailing Race (CEOI12_race) C++14
15 / 100
1242 ms 4004 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn = 500 + 5;
int n,k;
int way[maxn][maxn];
int dp[maxn][maxn][2];
int f(int u, int v, int t) {
	if(dp[u][v][t]==-1) {
        dp[u][v][t] = 0;
        int wow = (t==0 ? 1:-1);
		for(int x=(u+wow+n)%n;x!=v;x=(x+wow+n)%n) {
			if(!way[u][x]) continue;
			dp[u][v][t] = max(dp[u][v][t], max(f(x,u,!t), f(x,v,t)) + 1);
		}
	}
	return dp[u][v][t];
}
int main() {
	scanf("%d%d",&n,&k);
	if(k) assert(0);
	for(int u=0;u<n;u++) {
		int v;
		while(scanf("%d",&v) && v) way[u][v-1] = 1;
	}
	memset(dp,-1,sizeof(dp));
	pair<int,int> res = {-1,-1};
	for(int u=0;u<n;u++) res = max(res, {f(u,u,0), u});
	printf("%d\n%d",res.first,res.second);
}

Compilation message

race.cpp: In function 'int main()':
race.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&k);
  ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2424 KB Output is correct
2 Runtime error 4 ms 2424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 4 ms 2424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 4 ms 2424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Incorrect 7 ms 2740 KB Output isn't correct
6 Runtime error 3 ms 2740 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Correct 12 ms 2872 KB Output is correct
8 Runtime error 3 ms 2872 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Incorrect 18 ms 2880 KB Output isn't correct
10 Correct 24 ms 2924 KB Output is correct
11 Incorrect 26 ms 2924 KB Output isn't correct
12 Runtime error 3 ms 2924 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 4 ms 2924 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Incorrect 753 ms 3576 KB Output isn't correct
15 Runtime error 4 ms 3576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 3 ms 3576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 3 ms 3576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Incorrect 1242 ms 4004 KB Output isn't correct
19 Runtime error 3 ms 4004 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 3 ms 4004 KB Execution killed with signal 11 (could be triggered by violating memory limits)