![8)](./images/smilies/icon_cool.gif)
10340 - All in All
Moderator: Board moderators
Re: Why having WA with UVa 10340- All in All
It will be good if always remove your code after getting accepted. ![8)](./images/smilies/icon_cool.gif)
![8)](./images/smilies/icon_cool.gif)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
I'm getting WA on 10340 - All in All
Thanks lighted and brianfry! ![:D](./images/smilies/icon_biggrin.gif)
![:D](./images/smilies/icon_biggrin.gif)
Last edited by azisak on Thu Aug 21, 2014 9:30 am, edited 1 time in total.
Re: I'm getting WA on 10340 - All in All
Change reading to
Don't forget to remove your code after getting accepted. ![8)](./images/smilies/icon_cool.gif)
Code: Select all
while (cin>>subkal>>kal){
![8)](./images/smilies/icon_cool.gif)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
-
- 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
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.
Next time post in an existing thread.
Check input and AC output for thousands of problems on uDebug!
Re: 10340 - All in All
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;
}
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10340 - All in All
Try input: aa abb
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 1
- Joined: Mon Feb 09, 2015 10:58 am
Re: 10340 - All in All
Got AC jst after posting here. ![:)](./images/smilies/icon_smile.gif)
![:)](./images/smilies/icon_smile.gif)
Last edited by tahmidrana on Wed Feb 11, 2015 11:45 pm, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10340 - All in All
That is AC code.
Check input and AC output for thousands of problems on uDebug!
Re: 10340 - All in All
Accepted
.
![:D](./images/smilies/icon_biggrin.gif)
Code: Select all
Code Removed
Re: 10340 - All in All
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)