Page 1 of 2

Posted: Sat Mar 23, 2002 11:48 am
by LittleJohn
Hello:
I try to solve this problem, but I got so many WA and don't know why. Any tricks or something I may lose? please tell me, thank you very much! :smile:

Try these test cases

Posted: Mon Apr 29, 2002 10:50 am
by Anderson
tom hates jerry ,, jimmy hates tom
jimmy
a hate
jimmy hates tom ,
jimmy hate
tom hates jerry , jimmy hates tom
hates
jimmy hates tom
hate hate hate

output

Posted: Sun Aug 18, 2002 4:09 am
by Subeen
my prog produces the following outputs for ur given input and of course it got WA:

NO I WON’T
NO I WON’T
NO I WON’T
NO I WON’T
NO I WON’T
YES I WILL
NO I WON’T
YES I WILL
NO I WON’T


what's wrong?

WA?

Posted: Sun Aug 18, 2002 12:38 pm
by Even
this is my output according to the input above...

NO I WON

hi...

Posted: Sun Aug 18, 2002 4:49 pm
by Even
Hello...Subeen...

try this case ...

tom and tom and tom hatessssssssss tom , tom hates tom
tom lovesssssssss jimmy

both should be "YEW I WILL"...

tom like jum

should be "NO I WON'T" .... not "NO I WON

Posted: Mon Aug 19, 2002 12:55 pm
by Subeen
thankx... I got it AC. :D

Posted: Sat Sep 21, 2002 4:21 am
by Yarin
I'm getting WA on this one all the time, although it works on all inputs in this thread. Are the whitespace supposed to be exactly according to the formula, or may there be extra whitespace anywhere, like end of the line etc. Same thing, between two actions, should there always be exactly [space] [comma] [space]. Also, the ' character in "WON'T", which ASCII char is that anyway!? Doing a copy & paste from the problem description seems to indicate it's not the default ' character... but I'm not sure whether to trust the problem description.

Posted: Sat Sep 21, 2002 5:25 am
by LittleJohn
Hello, Yarin
I used strtok to parse the input string. Thus we can ignore extra whitespace anywhere. And, you're right, there will be exactly [spaces] [comma] [spaces]. Besides, you shouldn't copy & paste the ' character in sample output, just type ' and it will be fine. :wink:

Posted: Sat Sep 21, 2002 5:33 am
by arc16
hi,
yes, there might be LOT OF whitespace, including before eol.
so there would be something like:

Code: Select all

___tom__hatess___jerry___,_____mickey loves goofy______
'_' is whitespace
In the WON'T, it's ascii #39.

you could also try this:

Code: Select all

mickey lovess goofy and jerry , tom loves goofy and mickey and jerry,the jerry loves a goofy and a tom and a mickey and the jerry and the tom and the mickey and a jerry and a tom and a mickey,  tom loves a cat  ,jerry loves a dog
the answer is YES

Posted: Sat Sep 21, 2002 4:13 pm
by Yarin
Thanks, got AC finally!

10058-need I/O

Posted: Mon Nov 21, 2005 7:13 pm
by Zuberul
please give me some I/O.

thanks in advance.

Posted: Tue Nov 22, 2005 6:20 pm
by Zuberul
:D had a little refresh problem.
got AC.

10058 - WA

Posted: Wed Oct 04, 2006 3:24 am
by Johan
Hi,

I was wondering if someone might have some good testcases for my code. I was confused by:

- the extra words that seem to be in the input (I chose to regard them as wrong rather than ignore them)
- the apostroph in the output (I just copied it from the example output, even though it seems to have ascii value > 127)
- the "VERBs" in the definition of VERB (I chose to consider a given verb with any number of characters 's' behind it to be correct).

I hope someone can help me. :)

Kind regards,

Johan

Code: Select all

#include <iostream> 
#include <sstream> 
#include <string> 
#include <vector> 
#include <queue> 
#include <set> 
#include <map> 
#include <cstdio> 
#include <cstdlib> 
#include <cctype> 
#include <cmath> 
#include <list> 
#include <algorithm>
#include <numeric>
using namespace std; 


 // pre-written code
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<string> vs; 
typedef vector<vs> vvs;
#define pb push_back 
#define sz(v) ((int)(v).size()) 


vs splitvs(string s,string split)
{
  vs uit; string nu;
  split+=char(0); s+=char(0);
  for(int i=0;i<sz(s);i++)
  {
    if(split.find(s[i])!=string::npos)
    { if(sz(nu))uit.pb(nu); nu=""; }
    else nu+=s[i];
  }
  return uit;
}


vs NOUN, VERB;


bool isACTIVE_LIST(vs actlist)
{
  string res; int j;
  for(j=0;j<sz(actlist);j++)
    if(actlist[j]=="and")
      res+="&"; 
    else if(actlist[j]=="a"||actlist[j]=="the")
      res+="a";
    else if(find(NOUN.begin(),NOUN.end(),actlist[j])!=NOUN.end())
      res+="n";
    else
      return false;
  
  res="&"+res+"&";
  for(j=0;j<sz(res)-1;j++)
    if(res[j]=='&'&&res[j+1]=='&')
      return false;
 
  vs rr=splitvs(res,"&");
  for(j=0;j<sz(rr);j++)
    if(rr[j]!="n"&&rr[j]!="an")
      return false;

  return true;
}


bool isACTION(string action)
{
  vs act=splitvs(action," ");
  int j,cnt=0,pos;
  for(j=0;j<sz(act);j++)
  {
    string strip=act[j];
    while(sz(strip)&&strip[sz(strip)-1]=='s') 
      strip=strip.substr(0,sz(strip)-1);
    if(find(VERB.begin(),VERB.end(),strip)!=VERB.end())
    {
      cnt++;
      pos=j;
    }
  }

  if(cnt!=1||pos==0||pos==sz(act)-1)
    return false;

  vs left,right;
  for(j=0;j<sz(act);j++)
    if(j<pos)
      left.pb(act[j]);
    else if(j>pos)
      right.pb(act[j]);

  return isACTIVE_LIST(left)&&isACTIVE_LIST(right);
}


char buf[1000000];
int main()
{
  int N,M,i,j,k;

  NOUN = splitvs("tom|jerry|goofy|mickey|jimmy|dog|cat|mouse","|");
  VERB = splitvs("hate|love|know|like","|");
  
  while(gets(buf))
  {
    string input=buf; if(sz(input)==0) break;
    vs actions=splitvs(input,",");
    
    bool allActions=true;
    for(j=0;j<sz(actions);j++)
      allActions&=isACTION(actions[j]);
    printf("%s\n",allActions?"YES I WILL":"NO I WON’T");
  }
  
  return 0;
}

Posted: Thu Nov 02, 2006 8:40 am
by Solaris
- the extra words that seem to be in the input (I chose to regard them as wrong rather than ignore them)
- the apostroph in the output (I just copied it from the example output, even though it seems to have ascii value > 127)
- the "VERBs" in the definition of VERB (I chose to consider a given verb with any number of characters 's' behind it to be correct).
According to my AC code:

1. Presence of extra word is wrong
2. apostrophy is NORMAL apostrophy
3. Your defn of VERB is the same as mine

Posted: Thu Mar 01, 2007 10:42 am
by sakhassan
Can anyone give me some critical input/output ?

Thanks in Advance