576 - Haiku Review
Moderator: Board moderators
576 WA PLEASE HELP
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;
}
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

http://acm.uva.es/problemset/usersjudge.php?user=37504
576 Haiku Review... WA.
i don't know why i got WA.
plz anybody help me... or give me sample input data...
here my code.
plz anybody help me... or give me sample input data...

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.
576 why WA
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.
Thanks
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;
}
}
Help me, because this is my homework for college.

Thanks

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;
}
}
-
- New poster
- Posts: 13
- Joined: Sat Oct 07, 2006 6:42 pm
- Contact:
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;
}
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???
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.
Test the case...
Input:
Output:
Hope it helps.
Input:
Code: Select all
aaa aa a a a/ abe a e y u o / i i i i
e/o/i
Code: Select all
3
Ami ekhono shopno dekhi...
HomePage
HomePage
-
- New poster
- Posts: 12
- Joined: Fri May 23, 2008 10:24 pm
Re: 576
I get WA though my outputs are correct for every inputs given in this forum. Can anyone tell where is the problem?
Regards.
"So there is nobody to help!?
"
"Well, this time i was able to solve it myself! but the problem i figured out was so silly....
"
Code: Select all
Removed after AC.
"So there is nobody to help!?

"Well, this time i was able to solve it myself! but the problem i figured out was so silly....

Re: WA againnnn
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");
}
}
"Accepted" is my passion but RTE is my weakness.....
Re: 576
getting WA
pls help
here is the code:

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/
http://akanoi.webs.com/
-
- Experienced poster
- Posts: 136
- Joined: Sat Nov 29, 2008 8:01 am
- Location: narayangong,bangladesh.
- Contact:
576:WA
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
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com
Re: 576
Try this...
My AC Output
Code: Select all
e i i i i/o i i i i i i/i
e/o/i
Code: Select all
3
-
- Experienced poster
- Posts: 136
- Joined: Sat Nov 29, 2008 8:01 am
- Location: narayangong,bangladesh.
- Contact:
Re: 576
Thanx Hank00544 for your help.
It was a stupid mistake.
It was a stupid mistake.

Life is more complicated than algorithm.
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com
Re: 576
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