10340 - All in All

All about problems in Volume 103. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: Why having WA with UVa 10340- All in All

Post by lighted » Wed Jul 16, 2014 2:11 pm

It will be good if always remove your code after getting accepted. 8)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

azisak
New poster
Posts: 4
Joined: Wed Aug 20, 2014 6:09 pm

I'm getting WA on 10340 - All in All

Post by azisak » Wed Aug 20, 2014 6:14 pm

Thanks lighted and brianfry! :D
Last edited by azisak on Thu Aug 21, 2014 9:30 am, edited 1 time in total.

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: I'm getting WA on 10340 - All in All

Post by lighted » Wed Aug 20, 2014 7:53 pm

Change reading to

Code: Select all

 while (cin>>subkal>>kal){
Don't forget to remove your code after getting accepted. 8)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: I'm getting WA on 10340 - All in All

Post by brianfry713 » Wed Aug 20, 2014 8:52 pm

Don't use cin.eof(), there will be a newline char at the end of the last line in the judge's input.
Next time post in an existing thread.
Check input and AC output for thousands of problems on uDebug!

Xenon Kfr
New poster
Posts: 13
Joined: Tue Nov 18, 2014 1:14 am

Re: 10340 - All in All

Post by Xenon Kfr » Tue Jan 27, 2015 11:44 pm

why WA ?

Code: Select all

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    while(cin>>s>>t)
    {
        if(cin.eof())
            return 0;
        int temp=0,yes=1,j;
        if(s.size()>t.size())
        {
            yes=0;
        }
        else if(s.size()==t.size())
        {
            if(s==t)
                yes=1;
            else
                yes=0;
        }
        else
            for(int i=0; s[i]; i++)
            {
                for(j=temp; t[j]; j++)
                {
                    if(s[i]==t[j])
                    {
                        temp=j;
                        break;
                    }
                    else if(j==t.size()-1)
                    {
                        yes=0;
                        break;
                    }
                }
//            if(j==t.size() && temp)
//            {
//                yes=0;
//                break;
//            }

            }
        if(yes==1)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}


brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10340 - All in All

Post by brianfry713 » Thu Jan 29, 2015 2:13 am

Try input: aa abb
Check input and AC output for thousands of problems on uDebug!

tahmidrana
New poster
Posts: 1
Joined: Mon Feb 09, 2015 10:58 am

Re: 10340 - All in All

Post by tahmidrana » Mon Feb 09, 2015 11:07 am

Got AC jst after posting here. :)
Last edited by tahmidrana on Wed Feb 11, 2015 11:45 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10340 - All in All

Post by brianfry713 » Tue Feb 10, 2015 1:38 am

That is AC code.
Check input and AC output for thousands of problems on uDebug!

prokawsar
New poster
Posts: 7
Joined: Tue Aug 04, 2015 5:01 pm

Re: 10340 - All in All

Post by prokawsar » Tue Aug 25, 2015 7:01 am

Accepted :D .

Code: Select all

Code Removed

astandrik
New poster
Posts: 2
Joined: Wed Aug 24, 2016 10:21 pm

Re: 10340 - All in All

Post by astandrik » Wed Aug 24, 2016 10:24 pm

Can anyone see why is it WA? All test cases are OK.

Code: Select all

import sys
def findSubstr(s1, s2):
    if(len(s2) == 0) or (len(s1) > len(s2)):
        return False
    elif s1[0] == s2[0] and len(s1) == 1:
        return True
    elif s1[0] == s2[0] and len(s1) > 1:
        return findSubstr(s1[1:], s2[1:])
    elif s1[0] != s2[0]:
        return findSubstr(s1,s2[1:])
try:
    while 1:
        line = sys.stdin.readline()
        inf = list(str(line).split())
        s1 = inf[0]
        s2 = inf[1]
        res = 'Yes' if findSubstr(s1,s2) else 'No'
        print(res)
except:
    exit(0)


Post Reply

Return to “Volume 103 (10300-10399)”