576 - Haiku Review

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

Moderator: Board moderators

fayyazkl
New poster
Posts: 11
Joined: Thu Mar 16, 2006 8:02 am
Location: Lahore, Pakistan

576 WA PLEASE HELP

Post by fayyazkl »

HI EVERYBODY!

I HAVE TRIED MY LEVEL BEST AND MY PROGRAM GIVES THE CORRECT ANSWER FOR EVERY INPUT I CAN THINK OF. BUT I AM GETTING WA. PLEASE TELL ME WHAT'S WRONG WITH THE CODE OR SUPPLY SOME INPUT ON WHICH MY PROGRAM FAILS!! THANK YOU


# include <iostream>
# include <cstring>
using namespace std;

main ()
{
char syll[205];

while (cin.getline(syll,202)) // input each syll
{

if ( strcmp(syll,"e/o/i") == 0 ) // terminate program
break;

int line=1;
int vowel=0, syllcount=0, flag=0;

for (int i=0; i<=strlen(syll); i++) // scan through each char
{
// if / then next line or \n then endofSyll
if (syll == '/' || syll== '\0')
{ // if first or third syllibi
if (line == 1 || line == 3 )
{
if (syllcount!=5) // if count less then quit
{
flag=1; // set flag for printing
break;
}
else syllcount=0; // else start count again for
} // next syllabi

else if (line == 2)
{
if (syllcount!=7)
{
flag=1; // set flag for printing
break;
}
else syllcount=0;
}

line++;
}
// check for vowel
else if (syll=='a'|| syll=='e'|| syll=='i'
|| syll=='o'|| syll=='u'|| syll=='y')
{
if (vowel==0) // if last char wasnt vowel then inc
syllcount++;
vowel=1; // flag showing last char was vowel
}

else vowel=0; // flag showing last char wasnt vowel
}

if (flag==0)
cout<< 'Y' << endl;
else cout << line << endl;

}

return 0;
}
There are 10 types of people. Those who can read binary and those who cant ;)
http://acm.uva.es/problemset/usersjudge.php?user=37504

bidol
New poster
Posts: 7
Joined: Sun Jul 10, 2005 1:14 pm

576 Haiku Review... WA.

Post by bidol »

i don't know why i got WA.
plz anybody help me... or give me sample input data... :D

here my code.

Code: Select all

#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;


bool isVowel(char c){
	switch(c)
	{
	case 'a':
	case 'e':
	case 'i':
	case 'o':
	case 'u':
	case 'y':
		return true;
		break;
	default:
		return false;
	    break;
	}
}

void main(){
	int i, j;
	char line[201];
	string str;
	int pos;
	int cnt;

	bool sucess;
	int non_correct_line_num;
	bool is_prev_moum;

	while(gets(line)){
		str = line;

		if(!strcmp(line, "e/o/i"))
			break;

		//cout << str << endl;

		sucess = true;
		pos = 0;
		for(i = 1; i <= 3; i++){

			cnt = 0;
			is_prev_moum = false;
			
			while(str[pos] != '/' && pos < str.size()){
				if(isVowel(str[pos++]) && !is_prev_moum){
					is_prev_moum = true;
					cnt++;				
				}
				else
					is_prev_moum = false;
			}


			if(i == 1 && cnt != 5){
				sucess = false;
				non_correct_line_num = 1;
				break;
			}
			else if(i == 2 && cnt != 7){
				sucess = false;
				non_correct_line_num = 2;
				break;
			}
			else if(i == 3 && cnt != 5){
				sucess = false;
				non_correct_line_num = 3;
				break;
			}

			pos++;
		}

		if(sucess)
			cout << 'Y' << endl;
		else
			cout << non_correct_line_num << endl;
	}

}
sorry, i'm not good at english.

Teja
New poster
Posts: 1
Joined: Tue Jan 09, 2007 3:15 pm

576 why WA

Post by Teja »

I have problems with my Java code for Haiku Review. Can anyone tell what I'm doing wrong.
Help me, because this is my homework for college.:roll:
Thanks :D

Here is my code:

class Main {

public static final int MAX = 100;

public static String readLine() {
int n = 0;
byte[] line = new byte[MAX];
try {
while(n < MAX) {
int znak = System.in.read();
if(znak < 0 || znak == '\n') break;
if(znak != '\r') line[n++] = (byte) znak;
}
}
catch(Exception e) {
return null;
}

if (n == 0) return null;
return new String(line, 0, n);
}

public static void main(String[] args) {

while(true) {
String vrstica = readLine();
vrstica = vrstica.toLowerCase();
String[] verz = split(vrstica, "/");
if(verz[0] == "e" && verz[1] == "o" && verz[2] == "i") break;

int n = verz[0].length();
int stevilo = 0;

for(int i = 0; i < n; ++i) {
char samoglasnik = verz[0].charAt(i);
if(samoglasnik == 'a') ++stevilo;
if(samoglasnik == 'e') ++stevilo;
if(samoglasnik == 'i') ++stevilo;
if(samoglasnik == 'o') ++stevilo;
if(samoglasnik == 'u') ++stevilo;
if(samoglasnik == 'y') ++stevilo;
}

if(stevilo != 5) System.out.println("1");

else {
int n2 = verz[1].length();
int stevilo2 = 0;

for(int i = 0; i < n2; ++i) {
char samoglasnik = verz[1].charAt(i);
if(samoglasnik == 'a') ++stevilo2;
if(samoglasnik == 'e') ++stevilo2;
if(samoglasnik == 'i') ++stevilo2;
if(samoglasnik == 'o') ++stevilo2;
if(samoglasnik == 'u') ++stevilo2;
if(samoglasnik == 'y') ++stevilo2;
}

if(stevilo2 != 7) System.out.println("2");

else {
int n3 = verz[2].length();
int stevilo3 = 0;

for(int i = 0; i < n3; ++i) {
char samoglasnik = verz[2].charAt(i);
if(samoglasnik == 'a') ++stevilo3;
if(samoglasnik == 'e') ++stevilo3;
if(samoglasnik == 'i') ++stevilo3;
if(samoglasnik == 'o') ++stevilo3;
if(samoglasnik == 'u') ++stevilo3;
if(samoglasnik == 'y') ++stevilo3;
}

if(stevilo3 != 5) System.out.println("3");
}
}
System.out.println("Y");
}
}

public static String[] split(String niz, String locilo) {
StringTokenizer st = new StringTokenizer(niz, locilo);
int n = st.countTokens();
String[] tokens = new String[n];
for(int i = 0; i < n; ++i) tokens = st.nextToken();
return tokens;
}
}

rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post by rio »

I'm not sure, but isn't the MAX value a little too small ?

! If there is already a thread for the problem, use it and don't create a new one.

john_locke
New poster
Posts: 13
Joined: Sat Oct 07, 2006 6:42 pm
Contact:

Post by john_locke »

hi friends i tried all the sample input from the forum but still get WA
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str;
string test = "e/o/i";
while(getline(cin,str))
{
if(str==test)
{
return 0;
}
else
{
int j=0;
int count[3];
for(int i=0;i<3;i++)
count=0;
bool inword=false;
for(int i=0;i<str.length();i++)
{
if(str>='A'&&str<='Z')
str=str-'A'+'a';
if(str=='/')
{j=j+1;}
else if(str=='a'||str=='e'||str=='i'||str=='o'||str[i]=='u'||str[i]=='y')
{
if (inword==false)
{
inword = true;
count[j]++;
}
}
else
inword=false;
}
/*for(int i=0;i<3;i++)
cout<<count[i]<<endl;*/
if(count[0]!=5)
{cout<<"1"<<endl;}
else if(count[1]!=7)
{cout<<"2"<<endl;}
else if(count[2]!=5)
{cout<<count[2]<<"3"<<endl;}
else
{cout<<"Y"<<endl;}
}
}
return 0;
}



RED-C0DE
New poster
Posts: 16
Joined: Mon Mar 26, 2007 6:47 pm

Post by RED-C0DE »

hi every one...

i checked my code with many test cases and it worked correctly but Judge sending me WA... please help what's wrong with my code???

Code: Select all

//576
AC
}
Last edited by RED-C0DE on Sun May 13, 2007 11:04 pm, edited 1 time in total.

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Test the case...

Input:

Code: Select all

aaa aa a a a/ abe a e y u o / i i i i
e/o/i
Output:

Code: Select all

3
Hope it helps.
Ami ekhono shopno dekhi...
HomePage

RED-C0DE
New poster
Posts: 16
Joined: Mon Mar 26, 2007 6:47 pm

Post by RED-C0DE »

tanks a lot... that's realy helpful.. I had silly mistake like everyone... (just != instead of <)..

however Tanks again.

The_Madman
New poster
Posts: 12
Joined: Fri May 23, 2008 10:24 pm

Re: 576

Post by The_Madman »

I get WA though my outputs are correct for every inputs given in this forum. Can anyone tell where is the problem?

Code: Select all

Removed after AC.  
Regards.

"So there is nobody to help!? :cry: "
"Well, this time i was able to solve it myself! but the problem i figured out was so silly.... :P "

empo
New poster
Posts: 19
Joined: Mon Jul 28, 2008 7:00 pm
Location: India

Re: WA againnnn

Post by empo »

Code: Select all

#include<iostream>
using namespace std;

int main()
{
	char str[200],str1[200],str2[200],str3[200];
	int i,j,flag,count;
	while(gets(str))
	{
		flag = 0;
		i =0;

		if(!strcmp(str,"e/o/i"))
			break;
		for(j=0;str[i]!='/';i++)
			str1[j++] = str[i];
		str1[j] = '\0';

		for(j=0,i=i+1;str[i]!='/';i++)
			str2[j++] = str[i];
		str2[j] = '\0';

		for(j=0,i=i+1;str[i]!='\n';i++)
			str3[j++] = str[i];
		str3[j] = '\0';

		count = 0;
		int len = strlen(str1);
		for(int k =0 ;k<len;k++)
		{
			if(str1[k]=='a' ||str1[k]=='e' ||str1[k]=='i' ||str1[k]=='o' ||str1[k]=='u' ||str1[k]=='y')
			{
				count++;
				k++;
				while((str1[k]=='a' ||str1[k]=='e' ||str1[k]=='i' ||str1[k]=='o' ||str1[k]=='u' ||str1[k]=='y') && k<len)
				{
					k++;
					continue;
				}
			}
		}
		if(count != 5)
		{
			flag =1;
			printf("1\n");
			continue;
		}

		count = 0;
		len = strlen(str2);
		for(int k =0 ;k<len;k++)
		{
			if(str2[k]=='a' ||str2[k]=='e' ||str2[k]=='i' ||str2[k]=='o' ||str2[k]=='u' ||str2[k]=='y')
			{
				count++;
				k++;
				while((str2[k]=='a' ||str2[k]=='e' ||str2[k]=='i' ||str2[k]=='o' ||str2[k]=='u' ||str2[k]=='y') && k<len)
				{
					k++;
					continue;
				}
			}
		}
		if(count != 7)
		{
			flag =1;
			printf("2\n");
			continue;
		}

		count = 0;
		len = strlen(str3);
		for(int k =0 ;k<len;k++)
		{
			if(str3[k]=='a' ||str3[k]=='e' ||str3[k]=='i' ||str3[k]=='o' ||str3[k]=='u' ||str3[k]=='y')
			{
				count++;
				k++;
				while((str3[k]=='a' ||str3[k]=='e' ||str3[k]=='i' ||str3[k]=='o' ||str3[k]=='u' ||str3[k]=='y') && k<len)
				{
					k++;
					continue;
				}
			}
		}
		if(count != 5)
		{
			flag =1;
			printf("3\n");
			continue;
		}
		if(flag==0)
			printf("Y\n");
	}
}

Please tell me why am i getting wrong answer again and again....
"Accepted" is my passion but RTE is my weakness.....

abid_iut
Learning poster
Posts: 82
Joined: Wed Jul 16, 2008 7:34 am

Re: 576

Post by abid_iut »

getting WA
pls help
here is the code:

Code: Select all

#include<stdio.h>
#include<string.h>

int check(char ch){
	if(ch=='a')return 1;
	if(ch=='e')return 1;
	if(ch=='i')return 1;
	if(ch=='o')return 1;
	if(ch=='u')return 1;
	if(ch=='y')return 1;
	else return 0;
}

int main()
{
	char dat[250];
	int i;
	while(gets(dat)){
		if(dat[0]==NULL)continue;
		if(dat[0]=='e' && dat[1]=='/' && dat[2]=='o' && dat[3]=='/' && dat[4]=='i')break;
		
		int line[3]={0},li=0,let=0,got;

		for(i=0;i<strlen(dat);i++){
			if(dat[i]>='A' && dat[i]<='Z'){
				dat[i]=dat[i]-'A'+'a';
			}
			got=check(dat[i]);
			if(got==1 && let==0){
				let=1;
				line[li]++;
			}
			else let=0;
			if(dat[i]=='/'){
				li++;
				let=0;
			}
		}
		
		if(line[0]!=5)printf("1\n");
		else if(line[1]!=7)printf("2\n");
		else if(line[2]!=5)printf("3\n");
		else printf("Y\n");
	}
	return 0;
}
:( :(
i love to wait... wait for better... and better will come...
http://akanoi.webs.com/

sazzadcsedu
Experienced poster
Posts: 136
Joined: Sat Nov 29, 2008 8:01 am
Location: narayangong,bangladesh.
Contact:

576:WA

Post by sazzadcsedu »

ACC.
Last edited by sazzadcsedu on Tue Aug 11, 2009 10:00 pm, edited 1 time in total.
Life is more complicated than algorithm.
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com

Hank00544
New poster
Posts: 3
Joined: Sun Jan 07, 2007 2:17 am

Re: 576

Post by Hank00544 »

Try this...

Code: Select all

e i i i i/o i i i i i i/i
e/o/i
My AC Output

Code: Select all

3

sazzadcsedu
Experienced poster
Posts: 136
Joined: Sat Nov 29, 2008 8:01 am
Location: narayangong,bangladesh.
Contact:

Re: 576

Post by sazzadcsedu »

Thanx Hank00544 for your help.
It was a stupid mistake. :D
Life is more complicated than algorithm.
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com

plamplam
Experienced poster
Posts: 150
Joined: Fri May 06, 2011 11:37 am

Re: 576

Post by plamplam »

Lol, I still couldn't find out why my program gets the verdict "Wrong Answer" here. I checked for all possible I/O but still WA. I finally gave up :(....This problem is not worth spending so much time. :(
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson

Post Reply

Return to “Volume 5 (500-599)”