# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
537609 | MinhAnhnd | Sailing Race (CEOI12_race) | C++14 | 443 ms | 16832 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <iostream>
#define ll long long
#define ull unsigned ll
using namespace std;
bool branches[501][501]={};
bool chaychua[501][501][2]={};
long N,K;
long dp[501][501][2]={};
vector<long> dp1 [501][501][2] = {};
long depth = -1;
long pre(long p){
if (p == 1) return N;
return p-1;
}
long nex(long p){
if (p == N) return 0;
return p+1;
}
long memo(long start, long end,long direction){
if (chaychua[start][end][direction]) return dp[start][end][direction];
chaychua[start][end][direction] = 1;
//counter-clockwise;
if (direction == 0){
for(long i = nex(start);i != end; i = nex(i)){
if (branches[start][i]){
dp[start][end][0] = max(dp[start][end][0],max(memo(i,end,0),memo(start,i,1))+1);
}
}
}
else{
for(long i = nex(start);i != end;i = nex(i)){
if (branches[end][i]){
dp[start][end][1] = max(dp[start][end][1],max(memo(i,end,0),memo(start,i,1))+1);
}
}
}
return dp[start][end][direction];
}
int main(){
cin>>N>>K;
long v,u=0;
for(long i = 1;i<=N;i++){
cin>>v;
while(v!=0){
branches[i][v]=1;
cin>>v;
}
}
long maxi = -1;
long mem = 0;
for(long i = 1;i<=N;i++){
//counter-clockwise
long val = memo(i,i,0);
if(val>=maxi){
maxi = val;
mem = i;
}
}
cout<<maxi<<endl<<mem<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |