Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
why wrong answer?#include<iostream> #include<cstring> using namespace std; int judge(string a,string b) { int c[500][500]; int na=a.length(); int nb=b.length(); for(int i=0;i<=na;i++) for(int j=0;j<=nb;j++) c[i][j]=0; for(int i=1;i<=na;i++) for(int j=1;j<=nb;j++) { if(a[i-1]==b[j-1]) c[i][j]=c[i-1][j-1]+1; else if(c[i-1][j]>c[i][j-1]) c[i][j]=c[i-1][j]; else c[i][j]=c[i][j-1]; } cout<<c[na][nb]; return c[na][nb]; } int main() { string a,b,c; int n; cin>>n; for(int i=1;i<=n;i++) { cin>>a>>b>>c; if(judge(a,c)+judge(b,c)==c.length()) cout<<"Data set "<<i<<": yes"<<endl; else cout<<"Data set "<<i<<": no"<<endl; } system("pause"); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator