10197 - Learning Portuguese

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

Moderator: Board moderators

sumankar
A great helper
Posts: 286
Joined: Tue Mar 25, 2003 8:36 am
Location: calcutta
Contact:

Explain Plz:

Post by sumankar » Mon Oct 27, 2003 8:14 pm

You mean something of
se laver(thats french though)
exists as a verb???
Suman.

deddy one
Experienced poster
Posts: 120
Joined: Tue Nov 12, 2002 7:36 pm

Post by deddy one » Wed Nov 12, 2003 1:28 pm

if the portuegese verb doesn't end with 'r'
then print the unknown conjugation right away.

Joseph Kurniawan
Experienced poster
Posts: 136
Joined: Tue Apr 01, 2003 6:59 am
Location: Jakarta, Indonesia

Post by Joseph Kurniawan » Wed Nov 12, 2003 3:27 pm

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.
There are 3 things one need to be successful : motivation, ability and chance. And if you're a believer, make it four : God's will.

mooseelkdog
New poster
Posts: 18
Joined: Fri Oct 10, 2003 8:46 am
Location: Airway Heights

10197 - Runtime Error

Post by mooseelkdog » Fri Dec 05, 2003 4:01 am

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

Ivor
Experienced poster
Posts: 150
Joined: Wed Dec 26, 2001 2:00 am
Location: Tallinn, Estonia

Post by Ivor » Tue Dec 23, 2003 8:30 pm

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
There is a theory which states that if ever anyone discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.

Guest
New poster
Posts: 39
Joined: Wed May 19, 2004 5:52 pm
Location: Dhaka, Bangladesh
Contact:

10197 WA

Post by Guest » Mon Jul 12, 2004 6:32 am

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. :)

User avatar
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

test cases

Post by sohel » Mon Jul 12, 2004 1:02 pm

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

Guest
New poster
Posts: 39
Joined: Wed May 19, 2004 5:52 pm
Location: Dhaka, Bangladesh
Contact:

Thanks!

Post by Guest » Mon Jul 12, 2004 4:28 pm

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!

User avatar
GVahe
New poster
Posts: 17
Joined: Thu Aug 05, 2004 6:04 pm
Location: Armenia
Contact:

10197 -learning portugese-WA?

Post by GVahe » Thu Oct 14, 2004 10:02 am

plz, help me i always get WA
give me some i/o for test

JackBauer
New poster
Posts: 19
Joined: Sun Mar 21, 2004 8:07 pm

Post by JackBauer » Wed Oct 27, 2004 1:19 am

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?

Raiyan Kamal
Experienced poster
Posts: 106
Joined: Thu Jan 29, 2004 12:07 pm
Location: Bangladesh
Contact:

Post by Raiyan Kamal » Wed Oct 27, 2004 3:38 pm

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

JackBauer
New poster
Posts: 19
Joined: Sun Mar 21, 2004 8:07 pm

Post by JackBauer » Wed Oct 27, 2004 11:12 pm

Thanks,

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

Fixed that, still gives WA.

Raiyan Kamal
Experienced poster
Posts: 106
Joined: Thu Jan 29, 2004 12:07 pm
Location: Bangladesh
Contact:

Post by Raiyan Kamal » Thu Oct 28, 2004 8:53 am

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. :)

acMustaine
New poster
Posts: 2
Joined: Mon Jun 06, 2005 4:36 am

10197 PE

Post by acMustaine » Mon Jun 06, 2005 4:43 am

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.

jurajz
Learning poster
Posts: 67
Joined: Sat Sep 02, 2006 7:30 pm
Location: Slovakia

Post by jurajz » Fri Feb 16, 2007 1:51 am

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.

Post Reply

Return to “Volume 101 (10100-10199)”

Who is online

Users browsing this forum: No registered users and 1 guest