11233 - Deli Deli

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

Moderator: Board moderators

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

11233 - Deli Deli

Post by palash » Sun Jun 15, 2008 9:27 pm

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

Post by palash » Sat Jun 28, 2008 1:51 am

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

Post by Chirag Chheda » Sat Jun 28, 2008 7:38 am

it is not a multiple input problem..

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

Re: 11233 - Deli Deli

Post by fushar » Sun Aug 30, 2009 9:14 am

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: ?????? ????? ?? ???, ?????? ??? ?? ????

11233 Deli Deli - Runtime Error. please help

Post by Shiba » Mon Jan 17, 2011 6:34 pm

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");
            }
        }
    }
}

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

Re: 11233 - Deli Deli

Post by uDebug » Tue Mar 18, 2014 9:20 am

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
buy
bay
grey
biy
too
vex
brash
nexus
chaste
park
label
snake
AC Output:

Code: Select all

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

Find us on Facebook. Follow us on Twitter.

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

Re: 11233 Deli Deli - Runtime Error. please help

Post by uDebug » Tue Mar 18, 2014 9:29 am

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!

Find us on Facebook. Follow us on Twitter.

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

Re: 11233 Deli Deli - Runtime Error. please help

Post by brianfry713 » Tue Mar 18, 2014 9:50 pm

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

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

Re: 11233 - Deli Deli

Post by sampad74 » Mon Aug 04, 2014 8:23 am

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

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

Re: 11233 - Deli Deli

Post by lighted » Mon Aug 04, 2014 4:45 pm

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: 30
Joined: Wed Jul 30, 2014 3:40 pm
Contact:

UVA 11233 - Deli Deli WA

Post by NAbdulla » Mon Aug 18, 2014 7:57 pm

I can't understand the fault.
Please help...
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: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: UVA 11233 - Deli Deli WA

Post by lighted » Wed Aug 20, 2014 8:29 pm

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

Check your output here
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

Post by brianfry713 » Wed Aug 20, 2014 9:11 pm

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

Post Reply

Return to “Volume 112 (11200-11299)”