Page 2 of 4

Explain Plz:

Posted: Mon Oct 27, 2003 8:14 pm
by sumankar
You mean something of
se laver(thats french though)
exists as a verb???
Suman.

Posted: Wed Nov 12, 2003 1:28 pm
by deddy one
if the portuegese verb doesn't end with 'r'
then print the unknown conjugation right away.

Posted: Wed Nov 12, 2003 3:27 pm
by Joseph Kurniawan
Hello sumankar, maybe it'll be more helpful if you post your code here so it can be evaluated. Or at least you can tell where your confusion lies. Besides I think (only a thought, not yet a conclusion) that the judging for this prob is buggy (Note that this is merely an assumption). I'll post later my AC code and my 'should be AC' code.

10197 - Runtime Error

Posted: Fri Dec 05, 2003 4:01 am
by mooseelkdog
I compile and run this fine off my computer, using g++, why does UVA give me a runtime error for this?

Code: Select all

/*Learning Portuguese #10197*/
#include <iostream>
#include <cstring>
#include <cassert>
#include <string>

using namespace std;

#define PORT_O 243

class CPort
{
	public:

		CPort();
		CPort(string, string);
		~CPort();

		void setVerb(string);
		void setTransl(string);
		void setRoot();
		void setTv(string);
		void setKnown(string);

		string getVerb() const;
		string getTransl() const;
		string getRoot() const;
		string getTv() const;
		bool getKnown() const;

	private:
		string verb, root ,transl , tv;
		bool known;

};

ostream &operator<< (ostream &, const CPort &);

int main()
{
	CPort * word;
	string ve, tr;

	while(cin >> ve)
	{
		cin.get();
		cin >> tr;
		cin.get();
		word = new CPort(ve, tr);
		cout << *word;
		
	} // end while

	return 0;

} // end main()

CPort::CPort()
{
	verb = "";
	transl = "";

} // end default CPort constructor

CPort::CPort(string v, string t)
{
	setVerb(v);
	setTransl(t);

} // end explicit CPort constructor

CPort::~CPort()
{
	verb = "";
	transl = "";

} // end CPort DESTRUCTOR

void CPort::setVerb(string v)
{
	verb = v;
	setKnown(verb);
	
	if(getKnown())
		setRoot();

} // end setVerb()

void CPort::setTransl(string t)
{
	transl = t;

} // end setTransl()

void CPort::setRoot()
{
	root = verb.substr(0, verb.length() - 2);
		
} // end setRoot()

void CPort::setTv(string l)
{
	tv = l;

} // end setTv()

void CPort::setKnown(string v)
{
	known = true;
	string ar = "ar";
	string er = "er";
	string ir = "ir";
	string temp;
	
	int length;
	
	length = v.length();

	if((v.substr(length - 2, 2) == ar) ||
		(v.substr(length - 2, 2) == er) ||
		(v.substr(length - 2, 2) == ir))
		setTv(v.substr(length - 2, 1));
	else
		known = false;

} // end setKnown()

string CPort::getVerb() const {return verb;} // end getVerb()
string CPort::getTransl() const {return transl;} // end getTransl()
string CPort::getRoot() const {return root;} // end getRoot()
string CPort::getTv() const {return tv;} // end getTv()
bool CPort::getKnown() const {return known;} // end getKnown()

ostream &operator<< (ostream & out, const CPort & A)
{
	string temp, eu, tu, ele, vo, eles;
	
	char nos[] = {'n', PORT_O, 's', '\0'};
	char vos[] = {'v', PORT_O, 's', '\0'};

	(A.getTv() == "i") ? tu = "es" : tu = A.getTv() + "s";
	(A.getTv() == "i") ? ele = "e" : ele = A.getTv();
	(A.getTv() == "i") ? vo = A.getTv() + "s" : vo = A.getTv() + "is";
	(A.getTv() == "i") ? eles = "em" : eles = A.getTv() + "m";

	if(A.getKnown())
	{
		temp += A.getVerb() + " (to " + A.getTransl() + ")" +
			"\neu         " + A.getRoot() + "o" +
			"\ntu         " + A.getRoot() + tu +
			"\nele/ela    " + A.getRoot() + ele +
			"\n" + nos + "        " + A.getRoot() + A.getTv() + "mos" +
			"\n" + vos + "        " + A.getRoot() + vo +
			"\neles/elas  " + A.getRoot() + eles + "\n\n";

		out << temp;

	} // end if
	else
		out << A.getVerb() << " (to " << A.getTransl() << ")"
			<< "\nUnknown conjugation\n\n";

	return out;

} // end ostream operator<< overload

Posted: Tue Dec 23, 2003 8:30 pm
by Ivor
Thought I just might drop this one. A word can consist of only a valid suffix, ie length of the root of the word is 0. I assumed otherwise, so got a bit of nasty testing.

Ivor

10197 WA

Posted: Mon Jul 12, 2004 6:32 am
by Guest
Hi Sohel,

I'm also getting WA for this problem. You've posted "I consdered two lettered portugese words as having no conjugation. But in this program this is not so. ", could you please explain what do you mean by this?

I thought that every word in the input should have two letter suffix at the end. So two letter words can be the suffixes only. But still I'm getting WA. So please help me.

It would be better if you'd provide some critical inputs. That way it would be easier for me to find my mistake.

Thank you. :)

test cases

Posted: Mon Jul 12, 2004 1:02 pm
by sohel
I thought two lettered words ( suppose ir ) had no conjugation. But I was wrong.

Here is some test cases you can try :

INPUT :
falar talk
ir sohel
or turjo
i cry
sir pray
tirr con
abcdef do

OUTPUT:
falar (to talk)
eu falo
tu falas
ele/ela fala
n

Thanks!

Posted: Mon Jul 12, 2004 4:28 pm
by Guest
A B-i-G thanks to Sohel :wink: for the help, (and so fast too :D )
I've got accepted.

My mistake was that for 2 letter words i was printing the word as well, where i was supposed to print the "o,es,e,imos" etc only.

Thanks again!

10197 -learning portugese-WA?

Posted: Thu Oct 14, 2004 10:02 am
by GVahe
plz, help me i always get WA
give me some i/o for test

Posted: Wed Oct 27, 2004 1:19 am
by JackBauer
Hello, I'm having trouble with this same problem. I'll use this thread to avoid creating a new one. The code is getting WA.

My algorithm and some implementation info:

Code: Select all

while loop fetching two strings with scanf until eof
  show the portuguese verb and the english correspondent
  get last char and the tv char into char variables
  switch the tv var
    case 'a', conj = 1
    case 'e', conj = 2
    case 'i', conj = 3
    default, conj = 0
  get the root to a string variable
  if last char is not 'r', conj = 0
  if conj = 0
    show unknow
  else if conj = 1 or conj = 2
    show 1st or 2nd conjugations
  else if conj = 3
    show 3rd conjugation
Any suggestions?

Posted: Wed Oct 27, 2004 3:38 pm
by Raiyan Kamal
Dear JackBauer,

What is your output for this case ?

Code: Select all

partir go away
my ac code gives this output

Code: Select all

partir (to go away)
eu        parto
tu        partes
ele/ela   parte
n

Posted: Wed Oct 27, 2004 11:12 pm
by JackBauer
Thanks,

indeed that breaks my code since I was assuming the english verb part would be a single word.

Fixed that, still gives WA.

Posted: Thu Oct 28, 2004 8:53 am
by Raiyan Kamal
to JackBauer,

I used to scanf("%s") the Portugese part then scanf("%c") to get the spaces and then gets() to take the english part. Your algo seems OK to me. Chek the spellings carefully, very carefully. You know what sort of problem is this one. :)

10197 PE

Posted: Mon Jun 06, 2005 4:43 am
by acMustaine
I post my code and i get PE. I have 2 ideas about:

a) I dont know if the words (english or portuguese) can have spaces. I supposse that they won't have.
b) I suppossed that i get PE because i always in each case print two '\n' at the end of the output.

If you know something about please write.

Posted: Fri Feb 16, 2007 1:51 am
by jurajz
Before AC of this problem, I had 2 PE's.

a) I read the line with two words, I found first space (ASCII 32) and I supposed, that before this space is portuguese word and behind this space is english word. Also - portuguese word cannot have space (if it not so, I will have WA), english word may have spaces.

b) Empty line should be behind each case except the last case. Or - empty line should be before each case except first case. Also, at the end of the output shouldn't be blank line.

I had PE because I printed too many blanks between conjugators and verbs. I printed the verbs in 12th column (correct is 11th column).

I have no more idea for having PE.

Please sorry for my bad english.