편집을 취소할 수 있습니다. 이 편집을 되돌리려면 아래의 바뀐 내용을 확인한 후 게시해주세요.
최신판 | 당신의 편집 | ||
28번째 줄: | 28번째 줄: | ||
if( c1+1<M && a[r1][c1+1] != '#') { | if( c1+1<M && a[r1][c1+1] != '#') { | ||
if( r2+1<N && a[r2+1][c2] != '#' ) res = Math.max(res, collect(r1,c1+1,r2+1,c2)+solve(r1,c1+1,r2+1)); | if( r2+1<N && a[r2+1][c2] != '#' ) res = Math.max(res, collect(r1,c1+1,r2+1,c2)+solve(r1,c1+1,r2+1)); | ||
if( | if( c1+1<M && a[r2][c1+1] != '#' ) res = Math.max(res, collect(r1,c1+1,r2,c2+1)+solve(r1,c1+1,r2)); | ||
} | } | ||
if( r1+1<N && a[r1+1][c1]!='#' ) { | if( r1+1<N && a[r1+1][c1]!='#' ) { | ||
if( c2+1<M && a[r2][c2+1] != '#' ) res = Math.max(res, collect(r1+1,c1,r2,c2+1)+solve(r1+1,c1,r2)); | if( c2+1<M && a[r2][c2+1] != '#' ) res = Math.max(res, collect(r1+1,c1,r2,c2+1)+solve(r1+1,c1,r2)); | ||
if( r2+1<N && a[r2+1][c2] != '#' ) res = Math.max(res, collect(r1+1,c1,r2+1 | if( r2+1<N && a[r2+1][c2] != '#' ) res = Math.max(res, collect(r1+1,c1,r2,c2+1)+solve(r1+1,c1,r2+1)); | ||
} | } | ||
dp[r1][c1][r2] = res; | dp[r1][c1][r2] = res; | ||
50번째 줄: | 50번째 줄: | ||
for(int[] t2: t1) Arrays.fill(t2, -1); | for(int[] t2: t1) Arrays.fill(t2, -1); | ||
} | } | ||
System.out.format("#%d %d\n", tc, solve(0,0,0) ); | |||
System.out.format("#%d %d\n", tc, | |||
} | } | ||
} | } | ||
85번째 줄: | 83번째 줄: | ||
{{소스헤더|출력}} | {{소스헤더|출력}} | ||
<source lang='text'> | <source lang='text'> | ||
#1 | #1 7 | ||
#2 | #2 8 | ||
#3 8 | #3 8 | ||
</source> | </source> |