Submission #1091410

#TimeUsernameProblemLanguageResultExecution timeMemory
1091410AtinaRSailing Race (CEOI12_race)C++14
40 / 100
400 ms4948 KiB
#include <bits/stdc++.h> using namespace std; int n,k; const int MAX=501; bool mat[MAX][MAX]; int vis[MAX][MAX][2]; int dp[MAX][MAX][2]; int f(int a, int b, int dir) { bool t=(dir==a); if(vis[a][b][t])return dp[a][b][t]; int res=0; for(int i=a+1; i!=b; i++) { if(i==n)i=0; if(i==b)break; if(mat[dir][i]) { res=max(res,f(a,i,i)+1); res=max(res,f(i,b,i)+1); } } vis[a][b][t]=true; dp[a][b][t]=res; return res; } int main() { cin>>n>>k; for(int i=0; i<n; i++) { int x; while(cin>>x) { if(x==0)break; x--; mat[i][x]=true; } } int poz,res=0; for(int i=0; i<n; i++) { int tmp=f(i,i,i); if(tmp>res) { res=tmp; poz=i; } } cout<<res<<endl<<poz+1<<endl; return 0; }

Compilation message (stderr)

race.cpp: In function 'int main()':
race.cpp:52:26: warning: 'poz' may be used uninitialized in this function [-Wmaybe-uninitialized]
   52 |     cout<<res<<endl<<poz+1<<endl;
      |                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...