Page 1 of 1

### 12289 - One-Two-Three

Posted: Tue May 15, 2012 6:43 pm
#include <iostream>
#include <string>
#include<cstdio>
#include<cmath>
using namespace std;

int main ()
{
int i,j,n,l,k;
string a;
string th="three";
scanf("%d",&n);
for(i=1; i<=n; i++)
{
cin>>a;
k=0;
l=a.length();
if(l==5)
{
for(j=0;j<5;j++)
{
if(a[j]==th[j])
k++;
}
if(k==4) printf("3");
}
else if(l==3)
{
if((a=='o'&&a=='n')||(a=='o'&&a=='e')||(a=='o'&&a=='e'))
printf("1");
else if((a=='t'&&a=='w')||(a=='t'&&a=='o')||(a=='w'&&a=='o'))
printf("2");
}
if(i!=n) printf("\n");
}
return 0;
}

### Re: 12289 Why wa

Posted: Tue May 15, 2012 6:44 pm
#include <iostream>
#include <string>
#include<cstdio>
#include<cmath>
using namespace std;

int main ()
{
int i,j,n,l,k;
string a;
string th="three";
scanf("%d",&n);
for(i=1; i<=n; i++)
{
cin>>a;
k=0;
l=a.length();
if(l==5)
{
for(j=0;j<5;j++)
{
if(a[j]==th[j])
k++;
}
if(k==4) printf("3");
}
else if(l==3)
{
if((a=='o'&&a=='n')||(a=='o'&&a=='e')||(a=='o'&&a=='e'))
printf("1");
else if((a=='t'&&a=='w')||(a=='t'&&a=='o')||(a=='w'&&a=='o'))
printf("2");
}
if(i!=n) printf("\n");
}
return 0;
}

### Re: Why wa

Posted: Tue May 15, 2012 10:45 pm
You should print a newline at the end.

### 12289 - Runtime Error

Posted: Mon Oct 08, 2012 10:01 pm
Hello,

I just started practicing JAVA. I've tried this problem many times but online-judge always says Runtime Error.
My question is why can I run it well on my own platform but not on online-judge?
How can I change the code to fit the online-judge's platform?
Thanks for everyone's help!

Code: Select all

``````import java.io.*;
import java.util.Scanner;

public class Main {
public static void main (String[] args) throws IOException
{
Scanner input = new Scanner (System.in);

int n=0;
String s;

for (n = input.nextInt(); n > 0; n--)
{
System.out.printf("%d\n", num(s));
}
}

private static int num(String s)
{
int c=0;

if (s.length()==5) return 3;
if (s.charAt(0)=='o') c++;
if (s.charAt(1)=='n') c++;
if (s.charAt(2)=='e') c++;

if (c >= 2) return 1;
else return 2;

}
}
``````

### Re: 12289 - Runtime Error

Posted: Tue Oct 09, 2012 10:18 pm

### Re: Why wa

Posted: Sun Dec 09, 2012 8:47 pm
Hi, I got WA,
But I believe that my solution has to be good.

Could anybody provide some cases for which my solution doesn't work

Code: Select all

``````AC
``````

### Re: Why wa

Posted: Mon Dec 10, 2012 9:55 pm
Try input:

Code: Select all

``````3
one
two
three``````

### Re: Why wa

Posted: Sun Dec 23, 2012 9:11 pm
Thank you, small mistake Got AC

### Re: Why wa

Posted: Fri Dec 06, 2013 3:52 pm
gives me WA too

java code

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Prob_32 {
public static void main(String[] args) throws IOException {

Scanner sc = new Scanner(System.in);

while(test-->0)
{

if(b.length()==3)
{
if(b.charAt(0)=='o'||b.charAt(1)=='n'||b.charAt(2)=='e')
{
System.out.println(1);
}
else if(b.charAt(0)=='t'&&b.charAt(b.length()-1)=='o'||b.charAt(1)=='w')
{
System.out.println(2);

}

}

if(b.length()==5)
{

System.out.println(3);

}
}

}

}

### Re: Why wa

Posted: Fri Dec 06, 2013 10:03 pm
Use class Main

### Re: Why wa

Posted: Sat Dec 07, 2013 8:14 am
new code

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

public static void main(String[] args) throws IOException {

Scanner sc = new Scanner(System.in);

int test = sc.nextInt();String b="";
while(test-->0)
{
b=sc.next();

if(b.length()==3)
{
if(b.charAt(0)=='o'||b.charAt(1)=='n'||b.charAt(2)=='e')
{
System.out.println(1);
}
else if(b.charAt(0)=='t'&&b.charAt(b.length()-1)=='o'||b.charAt(1)=='w')
{
System.out.println(2);

}

}

if(b.length()==5)
{

System.out.println(3);

}
}

}

}

### Re: Why wa

Posted: Wed Dec 11, 2013 12:20 am
That code won't compile.

### Re: Why wa

Posted: Fri Dec 13, 2013 8:15 am
Here is some test input / output.

Input:

Code: Select all

``````14
owe
too
theee
ote
owe
tne
txo
ont
wwo
wne
twx
one
two
three``````
AC output:

Code: Select all

``````1
2
3
1
1
1
2
1
2
1
2
1
2
3``````