| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 356833 | nicolaalexandra | Round words (IZhO13_rowords) | C++14 | 48 ms | 16952 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define DIM 1010
using namespace std;
char a[DIM],b[DIM],a2[DIM],b2[DIM];
int dp_left[DIM][DIM],dp_right[DIM][DIM];
int n,m,i,j,sol;
void solve (char a[], char b[]){
memset (dp_left,0,sizeof dp_left);
memset (dp_right,0,sizeof dp_right);
dp_left[0][0] = 1;
for (i=1;i<=n;i++)
for (j=1;j<=m;j++){
dp_left[i][j] = max (dp_left[i-1][j],dp_left[i][j-1]);
if (a[i] == b[j])
dp_left[i][j] = max (dp_left[i][j],dp_left[i-1][j-1] + 1);
}
dp_right[n+1][m+1] = 1;
for (i=n;i;i--)
for (j=m;j;j--){
dp_right[i][j] = max (dp_right[i+1][j],dp_right[i][j+1]);
if (a[i] == b[j])
dp_right[i][j] = max (dp_right[i][j],dp_right[i+1][j+1] + 1);
}
for (i=1;i<=n+1;i++)
for (j=1;j<=m+1;j++)
sol = max (sol,dp_right[i][j] + dp_left[i-1][j-1]);
}
int main (){
//ifstream cin ("date.in");
//ofstream cout ("date.out");
cin>>a+1>>b+1;
n = strlen (a+1), m = strlen (b+1);
for (i=1;i<=n;i++)
a2[n-i+1] = a[i];
for (i=1;i<=m;i++)
b2[m-i+1] = b[i];
solve (a,b);
solve (a,b2);
solve (a2,b);
solve (a2,b2);
cout<<sol;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
