제출 #66338

#제출 시각아이디문제언어결과실행 시간메모리
66338ikura355Sailing Race (CEOI12_race)C++14
15 / 100
2298 ms4672 KiB
#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);
	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);
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...