Page 5 of 5

Re: 531 - Compromise - WA

Posted: Tue Sep 03, 2013 9:42 pm
by brianfry713
You're printing a null character at the end of each line.

Re: 531 - Compromise - WA

Posted: Wed May 28, 2014 5:20 pm
by TLEorWA
PE..PE..PE :( :evil:
help..
here is my code:

Code: Select all

thnks brianfry713.AC  :) 

Why WA? I solved by DP - LCS

Posted: Wed Jun 11, 2014 10:00 pm
by lighted
sorry. look to next post

Re: 531 - Compromise - WA

Posted: Wed Jun 11, 2014 10:34 pm
by brianfry713
TLEorWA, Try the input
#
#

My AC code prints nothing, not even a blank line.

Re: 531 - Compromise - WA

Posted: Wed Jun 11, 2014 10:38 pm
by brianfry713
lighted, try running your code on the sample input.

Re: 531 - Compromise - WA

Posted: Sun Jun 15, 2014 1:45 pm
by lighted
I've changed my code. But wa. Maybe some problems with reading strings. Who can give some input tests?

Code: Select all

removed, after acc...
In one day third time i make same full mistake, not removing comments and read/write from files.

// #ifndef ONLINE_JUDGE
freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
// #endif

Re: 531 - Compromise - WA

Posted: Mon Jun 16, 2014 9:01 pm
by brianfry713
Don't read and write to files.

Re: 531 - Compromise PE error

Posted: Tue Sep 30, 2014 12:19 am
by incruator
I have tried every input Pleae Help .

Code: Select all

/*
Approach: Longest Common Subsequence
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>
#include<stack>
#include<queue>
#define PI 3.14159265
#define M 1000000007
#define EPS 1e-9
#define ll long long int
using namespace std;
const int N = 1000005;

int a[3005][3005];
vector<string>v;
int main()
{
//freopen("input.txt","r",stdin);
string s0;
while(getline(cin,s0))
{
if(s0.size()==0)break;
//cout<<" fuck "<<endl;
string s1[105]="",s2[105]="",s;int len1=0,len2=0;
//int c=0;
v.clear();
for(int i=0;i<s0.size();i++)
{

    if(s0=="#")break;
        if(s0[i]==' ')
        {
        //cout<<s1[len1] <<" ";
        len1++;continue;
        }
        s1[len1]+=s0[i];

    //len1++;
}
//cout<<s1[len1] <<endl;
len1++;
while(1 && s0!="#")
{
//cout<<"fuck"<<endl;
    getline(cin,s);
    if(s=="#")break;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]==' ')
        {
  //      cout<<s1[len1] <<" ";
        len1++;continue;
        }
        s1[len1]+=s[i];
    }
    len1++;
}

//cout<<s1[0]<<endl;
while(1)
{
    getline(cin,s);
    if(s=="#" || s.size()==0)break;
    //if(s.size()>0)
    //cout<<"funm?"<<endl;

    for(int i=0;i<s.size();i++)
    {
      //  cout<<"fuck"<<endl;
        if(s[i]==' ')
        {
        len2++;continue;
        }
        s2[len2]+=s[i];
    }
    len2++;
}
//cout<<s1[len1-1]<<" " <<s2[len2-1]<<endl;
for(int i=0;i<len1;i++)
{
    a[i][0]=0;
}
for(int j=0;j<len2;j++)
{
    a[0][j]=0;
}
for(int i=1;i<=len1;i++)
{
    for(int j=1;j<=len2;j++)
    {
        if(s1[i-1]==s2[j-1])
        {
            a[i][j]=a[i-1][j-1]+1;
        }
        else
        {
        a[i][j]=max(a[i-1][j],a[i][j-1]);
        }
    }
}
int i=len1,j=len2;
//cout<<len1<<" k "<<len2<<endl;
while(i>0 &&& j>0)
{
  //  cout<<i<<endl;
    if(a[i][j]==a[i-1][j])i--;
    else if(a[i][j]==a[i][j-1])j--;
    else
    {
        v.push_back(s1[i-1]);
        i--;j--;
    }
}
reverse(v.begin(),v.end());
if(v.size()>=1)
{
//cout<<v[0];
for(int i=0;i<v.size();i++)
{
    cout<<v[i];
    if(i!=v.size()-1)cout<<" ";
    else
    cout<<endl;
}
}
}
return 0;
}
@briyanfry
Thanks.. Please Help.. :) :oops: :oops: :oops:

Re: 531 - Compromise

Posted: Tue Sep 30, 2014 2:41 pm
by brianfry713
It looks like you figured it out.

Re: 531 - Compromise

Posted: Wed Oct 01, 2014 4:44 pm
by incruator
No The above code is still getting PE .. Can you tell wts wrong in that code.
Please ..
Thanks :oops: :oops:

Re: 531 - Compromise

Posted: Wed Oct 01, 2014 11:28 pm
by brianfry713
I saw on uhunt that you already got AC on this problem.

Try changing your input parsing. I got AC reading the input as strings, not line by line.

Re: 531 - Compromise

Posted: Fri Dec 12, 2014 10:02 am
by Shahidul.CSE

Code: Select all

Accepted ! 

Re: 531 - Compromise

Posted: Fri Dec 12, 2014 10:55 pm
by brianfry713
Input:

Code: Select all

a b c d e
#
b c d e a
#
a b a a
#
a a
#
AC output:

Code: Select all

b c d e
a a

Re: 531 - Compromise

Posted: Sat Dec 13, 2014 5:52 am
by Shahidul.CSE
Thanks, now got accepted :D