Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

why wrong answer?

Posted by wotiannu at 2009-03-19 18:11:38 on Problem 2192
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator