Submission #265104

# Submission time Handle Problem Language Result Execution time Memory
265104 2020-08-14T13:10:32 Z TadijaSebez Sailing Race (CEOI12_race) C++11
30 / 100
39 ms 1280 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
void ckmx(int&x,int y){x=max(x,y);}
const int N=305;
vector<int> E[N];
int dp[N][N][2],n;
bool was[N][N][2];
int DP(int l,int r,int side){
	if(was[l][r][side])return dp[l][r][side];
	int u=side==0?l:r;
	was[l][r][side]=1;
	int L=side==0?(l==n?1:l+1):l;
	int R=side==1?(r==1?n:r-1):r;
	for(int v:E[u]){
		if((l<=r&&l<=v&&r>=v)||(l>r&&(v<=r||v>=l))){
			ckmx(dp[l][r][side],1+max(DP(L,v,1),DP(v,R,0)));
		}
	}
	return dp[l][r][side];
}
int main(){
	scanf("%i %*i",&n);
	for(int i=1;i<=n;i++){
		while(1){
			int j;
			scanf("%i",&j);
			if(j==0)break;
			E[i].pb(j);
		}
	}
	int ans=-1,idx=0;
	for(int i=1;i<=n;i++){
		int now=DP(i,i==1?n:i-1,0);
		if(now>ans)ans=now,idx=i;
	}
	printf("%i\n%i\n",ans,idx);
	return 0;
}

Compilation message

race.cpp: In function 'int main()':
race.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |  scanf("%i %*i",&n);
      |  ~~~~~^~~~~~~~~~~~~
race.cpp:27:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |    scanf("%i",&j);
      |    ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Incorrect 1 ms 512 KB Output isn't correct
5 Correct 1 ms 512 KB Output is correct
6 Incorrect 2 ms 512 KB Output isn't correct
7 Correct 4 ms 512 KB Output is correct
8 Incorrect 2 ms 640 KB Output isn't correct
9 Correct 5 ms 640 KB Output is correct
10 Correct 15 ms 768 KB Output is correct
11 Correct 9 ms 768 KB Output is correct
12 Incorrect 18 ms 1024 KB Output isn't correct
13 Incorrect 39 ms 1280 KB Output isn't correct
14 Runtime error 2 ms 640 KB Execution killed with signal 11
15 Runtime error 5 ms 768 KB Execution killed with signal 11
16 Runtime error 4 ms 896 KB Execution killed with signal 11
17 Runtime error 4 ms 768 KB Execution killed with signal 11
18 Runtime error 2 ms 512 KB Execution killed with signal 11
19 Runtime error 5 ms 896 KB Execution killed with signal 11
20 Runtime error 6 ms 896 KB Execution killed with signal 11