Page 7 of 8

Re: Getting WA in 10815 - Andy's First Dictionary

Posted: Mon Dec 17, 2012 6:05 am
by alimbubt
Getting WA.....please help me....Is my input process is correct??

Code: Select all

Cut After Accepted

Re: Getting WA in 10815 - Andy's First Dictionary

Posted: Tue Dec 18, 2012 12:17 am
by brianfry713
There may be more than 27 words. You may be modifying s[-1]. You could use a set instead of a map.

Re: Getting WA in 10815 - Andy's First Dictionary

Posted: Tue Dec 18, 2012 10:08 am
by alimbubt

Code: Select all

Cut After Accepted

Re: Getting WA in 10815 - Andy's First Dictionary

Posted: Wed Dec 19, 2012 12:46 am
by brianfry713
input:

Code: Select all

don't
AC output:

Code: Select all

don
t

10815--getting WA

Posted: Fri Jun 14, 2013 10:54 am
by sun_kuet
Thanks GURU
I removed the code after accepted

Re: 10815--getting WA

Posted: Fri Jun 14, 2013 10:36 pm
by brianfry713
Don't add the null char to a c++ string.

Re: 10815 - Andy's First Dictionary

Posted: Mon Jul 22, 2013 3:37 pm
by Halah
Hello,, Good Afternoon :)

I got WA too for this problem .. I think the wrong with the space in the beginning of my output
but I couldn't change my code more to avoid this error.. how I can prevent my code to print this space in the beginning of my output!!

Code: Select all


import java.io.*;
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
        StringBuilder sb = new StringBuilder();
        Set<String> orderedSet = new TreeSet<String>();
        String s = br.readLine();

        while (s != null)
        {
            s = s.toLowerCase();
            String[] list = s.split(" "); 
            
            String word;
            String w, sp;
            
            boolean r = false;

            for (int i = 0; i < list.length; i++) {
                word = sp = "";
                w = list[i];
                for (int j = 0; j < list[i].length(); j++) {
                    
                    if ((w.charAt(j) >= 'a' && w.charAt(j) <= 'z'))
                    {
                        r = true;
                        word += w.charAt(j);
                        
                    }
                    else if(w.charAt(j) == '\'')
                    {
                        for (int k = ++j; k < list[i].length(); k++) {
                            sp += w.charAt(k);
                        }
                        
                        orderedSet.add(sp);
                        break;
                    }

                }
                if(r)
                    orderedSet.add(word);
                
            }

            s = br.readLine();
            
        }
        
        for (String i: orderedSet) {
                sb.append(i +"\n");
        }
        sb.deleteCharAt(sb.length()-1);
        System.out.println(sb);     
    }
}

Re: 10815 - Andy's First Dictionary

Posted: Tue Jul 23, 2013 1:18 am
by brianfry713
brianfry713 wrote:For an input file containing:

Code: Select all

a\bc
My AC output is:

Code: Select all

a
bc
I used the c function isalpha().

Re: 10815 - Andy's First Dictionary

Posted: Tue Jul 23, 2013 3:00 pm
by Halah
Thank you brianfry713 for your reply .. I corrected my code but uva still gives me WA!!
what is the wrong?

My updated code:

Code: Select all

import java.io.*;
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));

        StringBuilder sb = new StringBuilder();
        Set<String> orderedSet = new TreeSet<String>();
        String s = br.readLine();
        String word;
        String w, sp;
            

        while (s != null)
        {
            s = s.toLowerCase();
            String[] list = s.split(" "); 

            for (int i = 0; i < list.length; i++) {
                word = ""; sp = "";
                w = list[i];  
                boolean r1 = false;
                boolean r2 = true;
                for (int j = 0; j < w.length(); j++) {
                    
                    if ((w.charAt(j) >= 'a' && w.charAt(j) <= 'z'))
                    {
                        r1 = true;
                        word += w.charAt(j);
                        
                    } 
                    else
                    {
                        for (int k = ++j; k < list[i].length(); k++) {
                            if ((w.charAt(j) >= 'a' && w.charAt(j) <= 'z'))
                                r2= false;
                                sp += w.charAt(k);
                        }
                        if(!r2)
                            orderedSet.add(sp);
                        break;
                       
                    }

                }

                if(r1)
                  orderedSet.add(word);
                
            }

            s = br.readLine();
            
        }
        for (String i: orderedSet) {
             sb.append(i +"\n");
        }
        sb.deleteCharAt(sb.length()-1);
        System.out.println(sb);     
    }
}


Re: 10815 - Andy's First Dictionary

Posted: Wed Jul 24, 2013 11:49 am
by brianfry713
Try input:
a1b1c
Output should be:
a
b
c

Re: 10815 - Andy's First Dictionary

Posted: Wed Jul 24, 2013 9:57 pm
by Halah
brianfry713 wrote:Try input:
a1b1c
Output should be:
a
b
c
again WA!!!!!!!!
I gave up .. I will try another problem =)

Thanks for your help :oops:

Re: 10815 - Andy's First Dictionary

Posted: Mon Dec 09, 2013 9:13 pm
by omar_faruk
getting wrong answer please help..
my code: http://ideone.com/TiCxI1

Re: 10815 - Andy's First Dictionary

Posted: Wed Dec 11, 2013 12:33 am
by brianfry713
Don't use scanf("%[^EOF]",s);

Re: 10815 - Andy's First Dictionary

Posted: Fri Jan 10, 2014 8:25 am
by uDebug
Here's some input / output that helped me during testing / debugging.

Input:

Code: Select all

a\bc 1111111111x2222y1:""z,..,. e{g|f ThIsAWord222?#&*()! 
andy's--> 
~`cd()f:
;f^g9009?? /hijklmnop   
q r s
<<<<<z>>>>>
9u)v(w**%x#y
AC Output:

Code: Select all

a
andy
bc
cd
e
f
g
hijklmnop
q
r
s
thisaword
u
v
w
x
y
z

WA: 10815 - Andy's First Dictionary

Posted: Wed Apr 09, 2014 9:25 pm
by raihan_sust05
Getting WA!! :roll:
please anyone help

Code: Select all

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <vector>


#define pi acos(0)
#define inf 1<<30
#define max 10000
#define sz 5000
#define true 1
#define false 0
#define pb(a) push_back(a)
#define size(e) (int)e.size()
#define clr(a,b) memset(a,b,sizeof(a))

typedef long long int ll;

using namespace std;

set <string> S;

int main()
{
    char bin[sz];
    string tmp;
    while(gets(bin))
    {
//        getchar();
        int strln = strlen(bin);

        int i = 0;
        for(int j = 0; j <  strln; ++j)
            bin[j] = tolower(bin[j]);
        while(i < strln)
        {
            while(bin[i] >= 'a' && bin[i] <= 'z')
            {
                tmp.pb(bin[i]);
                ++i;
            }
            S.insert(tmp);
            tmp.clear();
            ++i;
        }
    }
    set <string> :: iterator sit;
    for(sit = S.begin(); sit != S.end(); ++sit)
        cout << *sit << endl;
    return 0;
}