UVa:10192 Vacation
제목의 뜻을 잘못 이해했다. 중복된 도시가 통계를 내지 않는 줄 알고 판정 결과 WA에 4번 가입했다.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
string str1,str2;
int dp[105][105];
int main()
{
int kase=0;
while(getline(cin,str1)&&str1[0]!='#')
{
memset(dp,0,sizeof(dp));
getline(cin,str2);
str1=' '+str1;
str2=' '+str2;
for(int i=1; i<str1.size(); ++i)
for(int j=1; j<str2.size(); ++j)
if(str1[i]==str2[j])
dp[i][j]=dp[i-1][j-1]+1;
else
dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
cout<<"Case #"<<++kase<<": you can visit at most "<<dp[str1.size()-1][str2.size()-1]<<" cities."<<endl;
}
return 0;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
01 가방, 완전 가방, 다중 가방 dp(동적 기획 입문 dp)01 가방은 2진법으로 직접 표시할 수 있지만 데이터 양이 너무 많으면 시간을 초과하는 것이 폭력이다.01 가방의 사상은 바로 이 물품에 대해 내가 넣은 가치가 큰지 안 넣은 가치가 큰지 비교하여 방정식 f[i][v...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.