# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
265106 | 2020-08-14T13:11:23 Z | TadijaSebez | Sailing Race (CEOI12_race) | C++11 | 347 ms | 3152 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=505; 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
# | 결과 | 실행 시간 | 메모리 | 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 | 512 KB | Output isn't correct |
4 | Incorrect | 1 ms | 512 KB | Output isn't correct |
5 | Correct | 1 ms | 640 KB | Output is correct |
6 | Incorrect | 1 ms | 640 KB | Output isn't correct |
7 | Correct | 4 ms | 768 KB | Output is correct |
8 | Incorrect | 2 ms | 768 KB | Output isn't correct |
9 | Correct | 5 ms | 768 KB | Output is correct |
10 | Correct | 15 ms | 896 KB | Output is correct |
11 | Correct | 7 ms | 896 KB | Output is correct |
12 | Incorrect | 21 ms | 1408 KB | Output isn't correct |
13 | Incorrect | 39 ms | 1916 KB | Output isn't correct |
14 | Correct | 63 ms | 2424 KB | Output is correct |
15 | Incorrect | 250 ms | 3064 KB | Output isn't correct |
16 | Incorrect | 301 ms | 3024 KB | Output isn't correct |
17 | Incorrect | 250 ms | 3108 KB | Output isn't correct |
18 | Correct | 83 ms | 2920 KB | Output is correct |
19 | Incorrect | 347 ms | 3152 KB | Output isn't correct |
20 | Incorrect | 347 ms | 3064 KB | Output isn't correct |