10197 - Learning Portuguese
Moderator: Board moderators
Explain Plz:
You mean something of
se laver(thats french though)
exists as a verb???
Suman.
se laver(thats french though)
exists as a verb???
Suman.
-
- Experienced poster
- Posts: 136
- Joined: Tue Apr 01, 2003 6:59 am
- Location: Jakarta, Indonesia
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.
-
- New poster
- Posts: 18
- Joined: Fri Oct 10, 2003 8:46 am
- Location: Airway Heights
10197 - Runtime Error
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
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
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.
10197 WA
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.
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
I thought two lettered words ( suppose ir ) had no conjugation. But I was wrong.
Here is some test cases you can try :
INPUT :
OUTPUT:
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!
A B-i-G thanks to Sohel for the help, (and so fast too )
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!
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?
plz, help me i always get WA
give me some i/o for test
give me some i/o for test
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:
Any suggestions?
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
-
- Experienced poster
- Posts: 106
- Joined: Thu Jan 29, 2004 12:07 pm
- Location: Bangladesh
- Contact:
Dear JackBauer,
What is your output for this case ?
my ac code gives this output
What is your output for this case ?
Code: Select all
partir go away
Code: Select all
partir (to go away)
eu parto
tu partes
ele/ela parte
n
-
- Experienced poster
- Posts: 106
- Joined: Thu Jan 29, 2004 12:07 pm
- Location: Bangladesh
- Contact:
-
- New poster
- Posts: 2
- Joined: Mon Jun 06, 2005 4:36 am
10197 PE
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.
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.
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.
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.