## 11233 - Deli Deli

Moderator: Board moderators

palash
New poster
Posts: 4
Joined: Wed Apr 16, 2008 8:49 pm

### 11233 - Deli Deli

I tried this problem to solve but every time i got WA. but why i can't understand . Please anybody help me. here is me code

Code: Select all

``````
At last ACC. i think i should be more watchful about code. :roll:

``````
Last edited by palash on Sat Aug 16, 2008 12:58 am, edited 2 times in total.

palash
New poster
Posts: 4
Joined: Wed Apr 16, 2008 8:49 pm

### Re: 11233 - Deli Deli

Is it a multiple test case problem?
please give me some test input and output...

Chirag Chheda
Learning poster
Posts: 74
Joined: Sat Jun 21, 2008 12:24 pm
Location: India

### Re: 11233 - Deli Deli

it is not a multiple input problem..

fushar
New poster
Posts: 26
Joined: Fri Apr 03, 2009 12:09 pm
Location: Indonesia
Contact:

### Re: 11233 - Deli Deli

just create a map<string, string> representing the irregular plural forms of the words in the description.

Shiba
New poster
Posts: 2
Joined: Thu Sep 09, 2010 7:20 pm
Location: ?????? ????? ?? ???, ?????? ??? ?? ????

i've got AC with the same alogorithm in C++. But in case of Java there is always RE . can anyone plz help me. where is my fault??

Code: Select all

``````import java.util.Scanner;

class Main {
static boolean vowel (char ch) {
if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') return true;
return false;
}
public static void main (String args[]) {
Scanner input = new Scanner(System.in);
int L, N, i, j, k;
String irregular[] = new String [25];
String plural[] = new String [25];
String word[] = new String [25];

L = input.nextInt();
N = input.nextInt();

for(i=0; i<L; i++) {
irregular[i] = input.next();
plural[i] = input.next();
}
for(i=0; i<N; i++)
word[i] = input.next();

for(i=0; i<N; i++) {
for(k=0; k<L; k++) {
if(word[i].compareTo(irregular[k]) == 0) {
System.out.println(plural[k]);
break;
}
}
if(k == L) {
int len = word[i].length();
if(word[i].charAt(len-1) == 'y' && len > 1 && !vowel(word[i].charAt(len-2))) {
for(j=0; j<len-1; j++)
System.out.print(word[i].charAt(j));
System.out.println("ies");
}
else if (word[i].charAt(len-1) == 'o' || word[i].charAt(len-1) == 's' || word[i].charAt(len-1) == 'x')
System.out.println(word[i] + "es");
else if (word[i].charAt(len-1) == 'h' && len > 1) {
if(word[i].charAt(len-2) == 'c' || word[i].charAt(len-2) == 's')
System.out.println(word[i] + "es");
else
System.out.println(word[i] + "s");
}
else
System.out.println(word[i] + "s");
}
}
}
}
``````

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

### Re: 11233 - Deli Deli

Here's some input / output that I found useful during testing / debugging.

Input:

Code: Select all

``````3 20
rice rice
spaghetti spaghetti
octopus octopi
rice
lobster
spaghetti
strawberry
octopus
peach
turkey
boy
bay
grey
biy
too
vex
brash
nexus
chaste
park
label
snake
``````
AC Output:

Code: Select all

``````rice
lobsters
spaghetti
strawberries
octopi
peaches
turkeys
boys
bays
greys
biys
tooes
vexes
brashes
nexuses
chastes
parks
labels
snakes
``````
Check input and AC output for over 7,500 problems on uDebug!

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Shiba wrote:i've got AC with the same alogorithm in C++. But in case of Java there is always RE . can anyone plz help me. where is my fault??
Looks like

Code: Select all

``Scanner input``
is never closed. Perhaps this could contribute to the RE.
Check input and AC output for over 7,500 problems on uDebug!

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

1 ? N ? 100
Check input and AC output for thousands of problems on uDebug!

New poster
Posts: 29
Joined: Wed Jun 18, 2014 3:57 pm

### Re: 11233 - Deli Deli

got AC.thanks lighted
Last edited by sampad74 on Mon Aug 04, 2014 6:20 pm, edited 1 time in total.

lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

### Re: 11233 - Deli Deli

You are reusing variable l, first for number of irregular words and second for length of each given word.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

NAbdulla
New poster
Posts: 31
Joined: Wed Jul 30, 2014 3:40 pm
Contact:

### UVA 11233 - Deli Deli WA

I can't understand the fault.
My Code:

Code: Select all

``````#include <stdio.h>
#include <string.h>
int isConsonant(char ch)
{
int f = 1;
if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u'){
f = 0;
}
else{
f = 1;
}
return f;
}
int comp(char s1[], char s2[])
{
int f = 0, i, l1 = 0, l2 = 0;
l1 = strlen(s1);
l2 = strlen(s2);
if(l1 == l2){
for(i = 0; i < l1; i++){
if(s1[i] != s2[i]){
f = 0;
break;
}
else{
f = 1;
}
}
}
return f;
}
int main()
{
int l, n, i, j, k, len, m, f, p, f1, l1;
char irr[105][205], tmp1[105], tmp2[105], instr[105];
scanf("%d %d", &l, &n);
getchar();
for(i = 0; i < l; i++){
gets(irr[i]);
}
for(i = 0; i < n; i++){
gets(instr);
f1 = 1;
for(j = 0; j < l; j++){
len = 0;
for(p = 0; irr[j][p] != '\0'; p++){
len++;
}
m = 0;
f = 0;
f1 = 1;
for(k = 0; k <= len; k++){
if(irr[j][k] != ' ' && f == 0){
tmp1[m++] = irr[j][k];
}
else if(irr[j][k] != '\0' && f == 1){
tmp2[m++] = irr[j][k];
}
else if(irr[j][k] == ' '){
tmp1[m++] = '\0';
m = 0;
f = 1;
}
else if(irr[j][k] == '\0'){
tmp2[m] = '\0';
f = 0;
}
}
if(comp(tmp1, instr) == 1){
printf("%s\n", tmp2);
f1 = 0;
break;
}
}
if(f1 == 1){
l1 = strlen(instr);
if((isConsonant(instr[l1-2]) == 1) && (instr[l1-1] == 'y')){
for(i = 0; i < l1-1; i++){
printf("%c", instr[i]);
}
printf("ies\n");
}
else if(instr[l1-1] == 'o' || instr[l1-1] == 's' || instr[l1-1] == 'x'){
printf("%s", instr);
printf("es\n");
}
else if((instr[l1-2] == 'c' || instr[l1-2] == 's') && instr[l1-1] == 'h'){
printf("%s", instr);
printf("es\n");
}
else{
printf("%s", instr);
printf("s\n");
}
}
}
return 0;
}``````

lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

### Re: UVA 11233 - Deli Deli WA

Check input posted by v1n1t in thread below. Your program doesn't output answer for last 6 words.
http://acm.uva.es/board/viewtopic.php?f ... 0d#p370523

http://ideone.com/0axqai

You can read irregular words simpler this way.

Code: Select all

``````scanf("%d %d", &l, &n);

char singular[30][30], plural[30][30];

for(i = 0; i < l; i++) {

while (getchar() != '\n');

scanf(" %s %s", singular[i], plural[i]);
}``````
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 11233 - Deli Deli

Next time post in an existing thread.
Check input and AC output for thousands of problems on uDebug!