124 - Following Orders

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

Moderator: Board moderators

Iwashere
New poster
Posts: 20
Joined: Mon Aug 11, 2003 1:50 pm
Location: Singapore

Post by Iwashere » Wed May 04, 2005 4:36 pm

03526697_24.c:22: parse error before character 0232
I think you have stray characters 0x9A in your code.

CDiMa
Experienced poster
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Re: CE in problem 124 [why error messages are so dumb?]

Post by CDiMa » Wed May 04, 2005 6:14 pm

OZone wrote:Hi! I've compiled following code in MSVC7.1 and even in Borland C. Everything is fine. So why do it gets compile errors in online judge?
I recieved by e-mail tough list of errors but they did not give me any clue to understang the problems. What is the character 0232, and why my declared variables suddenly became undeclared? The code is:

Code: Select all

	*++p = l[u[i] = i];
Since the OJ compiler is old I'd go with safer syntax:

Code: Select all

	u[i] = i;
	*(++p) = l[i];
OZone wrote:

Code: Select all

		for (char *k, j = 0; j < n; ++j)
Again:

Code: Select all

		char *k,j;
		for(j=0;j<n;++j)
Hope this helps!

Ciao!!!

Claudio

User avatar
OZone
New poster
Posts: 6
Joined: Sun May 01, 2005 9:05 am
Location: Novosibirsk, Russia
Contact:

Post by OZone » Wed May 04, 2005 9:16 pm

Thanks all of you guys trying to help me. But I think It won't be compiled ever. I'll try something else.

chunyi81
A great helper
Posts: 293
Joined: Sat Jun 21, 2003 4:19 am
Location: Singapore

Post by chunyi81 » Thu May 05, 2005 8:10 am

Note that u have to submit as C++ code, not C code.
I try submitting for you with my account and see how.

I do not know how u got those compile errors.

Include the following headers:
#include <iostream>
#include <cstdio>
#include <cstring>

And make sure the file extension of the file you are submitting is *.cpp or *.cc.

Try with the online submission system and submitting as C++ code.
I tried that and your code actually gave accepted(P.E)

miracle
New poster
Posts: 10
Joined: Sat Apr 16, 2005 9:40 am

Why P.E.? 124

Post by miracle » Thu May 05, 2005 2:09 pm

I've got AC(P.E.),I cannot find why ? Anyone can help me?

//FileName : 124.cpp
//Author : Wang Bo

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

char vars[20],vartot;
char graph[20][20];
char res[21];
short indeg[20],jection[26];
short j;

void Produce(short k)
{
short i;

if(k==vartot)
{
res[k]='\0';
cout<<res<<endl;
return;
}
for(i=0;i<vartot;i++)
if(indeg==0)
{
res[k]=vars;
for(j=0;j<vartot;j++)
if(graph[j]=='y')
indeg[j]--;
indeg=-1;
Produce(k+1);
indeg=0;
for(j=0;j<vartot;j++)
if(graph[j]=='y')
indeg[j]++;
}
}

int main()
{
char line[200],a,b;
short i;

while(cin.good())
{
vartot=0;
memset(graph,'n',sizeof(graph));
memset(indeg,0,sizeof(indeg));
cin.getline(line,200);
for(i=0;line;i++)
if(line>='a' && line<='z')
vars[vartot++]=line;
sort(vars,vars+vartot);
for(i=0;i<vartot;i++)
jection[vars[i]-'a']=i;
cin.getline(line,200);
for(i=0,j=0;line[i];i++)
if(line[i]>='a' && line[i]<='z')
{
j++;
if(j==1)
a=line[i];
if(j==2)
{
j=0;
b=line[i];
indeg[jection[b-'a']]++;
graph[jection[a-'a']][jection[b-'a']]='y';
}
}
Produce(0);
cout<<endl;
}
return 0;
}

User avatar
ibrahim
Experienced poster
Posts: 149
Joined: Mon Feb 07, 2005 10:28 pm
Location: Northern University, Bangladesh
Contact:

Post by ibrahim » Thu May 05, 2005 4:41 pm

Code: Select all

#ifndef ONLINE_JUDGE 
   close(0); 
   open("input.txt", 0); 
#endif 
Will you please describe its function? (It's work)

CDiMa
Experienced poster
Posts: 214
Joined: Fri Oct 17, 2003 5:49 pm
Location: Genova

Post by CDiMa » Thu May 05, 2005 6:02 pm

ibrahim wrote:

Code: Select all

#ifndef ONLINE_JUDGE 
   close(0); 
   open("input.txt", 0); 
#endif 
Will you please describe its function? (It's work)
The program closes standard input and opens the file input.txt associating it with file descriptor 0.
Since this wouldn't work on the online judge and isn't allowed (restricted function) this section of code is #ifndeffed against ONLINE_JUDGE

Ciao!!!

Claudio

User avatar
OZone
New poster
Posts: 6
Joined: Sun May 01, 2005 9:05 am
Location: Novosibirsk, Russia
Contact:

Post by OZone » Thu May 05, 2005 8:30 pm

All that I needed to do is to

Code: Select all

#include <cstring>
.
Thanks to all. I will remember romblem 124 as a "Compiler nightmare"!
Большое спасибо всем, пока! )

Raj Ariyan
Learning poster
Posts: 70
Joined: Sat Feb 05, 2005 9:38 am
Location: Gurukul

About P.E

Post by Raj Ariyan » Wed Jun 08, 2005 7:22 am

Hi miracle,
You've printed extra new line after last output. cin.good() is not stop for EOF, so just change a little bit to avoid P.E.

You wrote :-
while(cin.good())
{
vartot=0;
memset(graph,'n',sizeof(graph));
memset(indeg,0,sizeof(indeg));
cin.getline(line,200);
change it to
flag=0;
while(cin.getline(line,200))
{
if(flag)
puts("");
vartot=0;
memset ......
..........
..........
flag=1; <-- it should be at the last line
}
So at first flag is 0 so it doesnt print any blank line, but after the last line it translate to 1 so second output start with a new line. So no extra blank line. And other is while(cin.getline(line,200)) when there is a EOF then it stop. Hope it helps, thanx.
Some Love Stories Live Forever ....

smap16501004
New poster
Posts: 3
Joined: Thu Jul 27, 2006 4:32 pm

124 ....i don't know why WA

Post by smap16501004 » Thu Jul 27, 2006 4:39 pm

here is my Code:

Code: Select all

#include<iostream>
#include<cstdlib>
#include<cstring>
using namespace std;
char in[1000];
char str[500];
char list[500];
char st[1000][500],s;
int n;
bool W[1000][1000];
void check()
{
     int i,j,k,f1,f2;
     bool t=true;
     for(i=0;i<n;i++)
         for(j=i+1;j<n;j++)
         {
             for(k=0;k<n;k++)
             {
                 if(list[k]==str[i])f1=k;
                 if(list[k]==str[j])f2=k;
             }
             if(W[f1][f2])
                 t=false;
         }
     if(t)
         strcpy(st[s++],str);
}
void recursion(int p)
{
    int i;
    char t;
    if(p==n-1)
    {
        check();
    }else{
        for(i=p;i<n;i++)
        {
            t=str[i];
            str[i]=str[p];
            str[p]=t;
            recursion(p+1);
            t=str[i];
            str[i]=str[p];
            str[p]=t;
        }
    }    
}

int main(void)
{
    int i,j,k,flag1,flag2;
    char strt[500];
    while(cin.getline(in,1000))
    {
        i=0;
        n=0;
        while(in[i]!='\0')
        {
            if(in[i]!=' ')
                str[n++]=in[i];
            i++;
        }
        str[n]='\0';
        strcpy(list,str);
        for(i=0;i<n;i++)
            for(j=0;j<n;j++)
                W[i][j]=0;
        cin.getline(in,1000);
        k=0;
        while(in[k]!='\0')
        {
            for(i=0;i<n;i++)
            {
                if(str[i]==in[k])flag1=i;
                if(str[i]==in[k+2])flag2=i;
            }
            W[flag2][flag1]=1;
            k+=4;
        }
        s=0;
        recursion(0);
        for(i=s-1;i>=0;i--)
            for(j=0;j<i;j++)
                if(strcmp(st[j],st[j+1])>0)
                {
                    strcpy(strt,st[j]);
                    strcpy(st[j],st[j+1]);
                    strcpy(st[j+1],strt);
                }
        for(i=0;i<s;i++)
            cout<<st[i]<<endl;
        cout<<endl;
    }
    return 0;
}
please help!!!!!!!!!!!!!!!!

crisy
New poster
Posts: 1
Joined: Sat Sep 02, 2006 7:45 pm

124 why WA, please help me

Post by crisy » Mon Sep 04, 2006 6:05 pm

I got WA for this problem but I don't know why
Please help me!!!
this is my pascal code


type
arr=array[1..20] of char;
var
s:arr;
l:array[1..50,1..2] of char;
n,i,j,q:byte;
c:char;
procedure hv(s:arr;k:integer);
var e,phu,p1,p2:byte; linh:0..1;
begin
for e:=k to n do
begin
c:=s[e]; s[e]:=s[k]; s[k]:=c;
if k=n-1 then
begin
linh:=0;
for phu:=1 to i do
begin
p1:=1; p2:=1;
while s[p1]<>l[phu,1] do inc(p1);
while s[p2]<>l[phu,2] do inc(p2);
if p1>p2 then break else if phu=i then linh:=1;
end;
if linh=1 then begin for phu:=1 to n do write(s[phu]); writeln; end;
end
else hv(s,k+1);
end;
end;
BEGIN
while not eof do
begin
n:=0;
if q=1 then writeln else q:=1;
while not eoln do
begin
read(c);
if c<>' ' then begin inc(n); s[n]:=c; end;
end;
readln; i:=0; j:=1;
while not eoln do
begin
read(c); if c<>' ' then begin if j=1 then inc(i); l[i,j]:=c; j:=3-j; end;
end;
hv(s,1);
readln;
end;
END.

Shafaet_du
Experienced poster
Posts: 147
Joined: Mon Jun 07, 2010 11:43 am
Location: University Of Dhaka,Bangladesh
Contact:

Re: 124 ....i don't know why WA

Post by Shafaet_du » Sat Oct 30, 2010 2:29 pm

This should help you if you are looking for sample cases:

Code: Select all

z a b c d e
a b c d z a a e
z a m n a q
q a a n m z z q
a b c d
a c b d
p o q a b c d e r
p o q a b c d e r e d p a o r q r c r b
output:

Code: Select all

cdzabe
cdzaeb
czabde
czabed
czadbe
czadeb
czaebd
czaedb
czdabe
czdaeb
zabcde
zabced
zabecd
zacbde
zacbed
zacdbe
zacdeb
zacebd
zacedb
zaebcd
zaecbd
zaecdb
zcabde
zcabed
zcadbe
zcadeb
zcaebd
zcaedb
zcdabe
zcdaeb

amzqan
mazqan
mzaqan
mzqaan
mzqaan
mzqana

abcd
abdc
acbd
bacd
badc
bdac

dprbceqao
dprbcqaeo
dprbcqaoe
dprbcqeao
dprbecqao
dprbeqaco
dprbeqaoc
dprbeqcao
dprbqaceo
dprbqacoe
dprbqaeco
dprbqaeoc
dprbqaoce
dprbqaoec
dprbqcaeo
dprbqcaoe
dprbqceao
dprbqeaco
dprbqeaoc
dprbqecao
dprebcqao
dprebqaco
dprebqaoc
dprebqcao
dpreqabco
dpreqaboc
dpreqaobc
dpreqbaco
dpreqbaoc
dpreqbcao
dprqabceo
dprqabcoe
dprqabeco
dprqabeoc
dprqaboce
dprqaboec
dprqaebco
dprqaeboc
dprqaeobc
dprqaobce
dprqaobec
dprqaoebc
dprqbaceo
dprqbacoe
dprqbaeco
dprqbaeoc
dprqbaoce
dprqbaoec
dprqbcaeo
dprqbcaoe
dprqbceao
dprqbeaco
dprqbeaoc
dprqbecao
dprqeabco
dprqeaboc
dprqeaobc
dprqebaco
dprqebaoc
dprqebcao
drbcepqao
drbceqapo
drbceqpao
drbcpeqao
drbcpqaeo
drbcpqaoe
drbcpqeao
drbcqaepo
drbcqapeo
drbcqapoe
drbcqeapo
drbcqepao
drbcqpaeo
drbcqpaoe
drbcqpeao
drbecpqao
drbecqapo
drbecqpao
drbepcqao
drbepqaco
drbepqaoc
drbepqcao
drbeqacpo
drbeqapco
drbeqapoc
drbeqcapo
drbeqcpao
drbeqpaco
drbeqpaoc
drbeqpcao
drbpceqao
drbpcqaeo
drbpcqaoe
drbpcqeao
drbpecqao
drbpeqaco
drbpeqaoc
drbpeqcao
drbpqaceo
drbpqacoe
drbpqaeco
drbpqaeoc
drbpqaoce
drbpqaoec
drbpqcaeo
drbpqcaoe
drbpqceao
drbpqeaco
drbpqeaoc
drbpqecao
drbqacepo
drbqacpeo
drbqacpoe
drbqaecpo
drbqaepco
drbqaepoc
drbqapceo
drbqapcoe
drbqapeco
drbqapeoc
drbqapoce
drbqapoec
drbqcaepo
drbqcapeo
drbqcapoe
drbqceapo
drbqcepao
drbqcpaeo
drbqcpaoe
drbqcpeao
drbqeacpo
drbqeapco
drbqeapoc
drbqecapo
drbqecpao
drbqepaco
drbqepaoc
drbqepcao
drbqpaceo
drbqpacoe
drbqpaeco
drbqpaeoc
drbqpaoce
drbqpaoec
drbqpcaeo
drbqpcaoe
drbqpceao
drbqpeaco
drbqpeaoc
drbqpecao
drebcpqao
drebcqapo
drebcqpao
drebpcqao
drebpqaco
drebpqaoc
drebpqcao
drebqacpo
drebqapco
drebqapoc
drebqcapo
drebqcpao
drebqpaco
drebqpaoc
drebqpcao
drepbcqao
drepbqaco
drepbqaoc
drepbqcao
drepqabco
drepqaboc
drepqaobc
drepqbaco
drepqbaoc
drepqbcao
dreqabcpo
dreqabpco
dreqabpoc
dreqapbco
dreqapboc
dreqapobc
dreqbacpo
dreqbapco
dreqbapoc
dreqbcapo
dreqbcpao
dreqbpaco
dreqbpaoc
dreqbpcao
dreqpabco
dreqpaboc
dreqpaobc
dreqpbaco
dreqpbaoc
dreqpbcao
drpbceqao
drpbcqaeo
drpbcqaoe
drpbcqeao
drpbecqao
drpbeqaco
drpbeqaoc
drpbeqcao
drpbqaceo
drpbqacoe
drpbqaeco
drpbqaeoc
drpbqaoce
drpbqaoec
drpbqcaeo
drpbqcaoe
drpbqceao
drpbqeaco
drpbqeaoc
drpbqecao
drpebcqao
drpebqaco
drpebqaoc
drpebqcao
drpeqabco
drpeqaboc
drpeqaobc
drpeqbaco
drpeqbaoc
drpeqbcao
drpqabceo
drpqabcoe
drpqabeco
drpqabeoc
drpqaboce
drpqaboec
drpqaebco
drpqaeboc
drpqaeobc
drpqaobce
drpqaobec
drpqaoebc
drpqbaceo
drpqbacoe
drpqbaeco
drpqbaeoc
drpqbaoce
drpqbaoec
drpqbcaeo
drpqbcaoe
drpqbceao
drpqbeaco
drpqbeaoc
drpqbecao
drpqeabco
drpqeaboc
drpqeaobc
drpqebaco
drpqebaoc
drpqebcao
drqabcepo
drqabcpeo
drqabcpoe
drqabecpo
drqabepco
drqabepoc
drqabpceo
drqabpcoe
drqabpeco
drqabpeoc
drqabpoce
drqabpoec
drqaebcpo
drqaebpco
drqaebpoc
drqaepbco
drqaepboc
drqaepobc
drqapbceo
drqapbcoe
drqapbeco
drqapbeoc
drqapboce
drqapboec
drqapebco
drqapeboc
drqapeobc
drqapobce
drqapobec
drqapoebc
drqbacepo
drqbacpeo
drqbacpoe
drqbaecpo
drqbaepco
drqbaepoc
drqbapceo
drqbapcoe
drqbapeco
drqbapeoc
drqbapoce
drqbapoec
drqbcaepo
drqbcapeo
drqbcapoe
drqbceapo
drqbcepao
drqbcpaeo
drqbcpaoe
drqbcpeao
drqbeacpo
drqbeapco
drqbeapoc
drqbecapo
drqbecpao
drqbepaco
drqbepaoc
drqbepcao
drqbpaceo
drqbpacoe
drqbpaeco
drqbpaeoc
drqbpaoce
drqbpaoec
drqbpcaeo
drqbpcaoe
drqbpceao
drqbpeaco
drqbpeaoc
drqbpecao
drqeabcpo
drqeabpco
drqeabpoc
drqeapbco
drqeapboc
drqeapobc
drqebacpo
drqebapco
drqebapoc
drqebcapo
drqebcpao
drqebpaco
drqebpaoc
drqebpcao
drqepabco
drqepaboc
drqepaobc
drqepbaco
drqepbaoc
drqepbcao
drqpabceo
drqpabcoe
drqpabeco
drqpabeoc
drqpaboce
drqpaboec
drqpaebco
drqpaeboc
drqpaeobc
drqpaobce
drqpaobec
drqpaoebc
drqpbaceo
drqpbacoe
drqpbaeco
drqpbaeoc
drqpbaoce
drqpbaoec
drqpbcaeo
drqpbcaoe
drqpbceao
drqpbeaco
drqpbeaoc
drqpbecao
drqpeabco
drqpeaboc
drqpeaobc
drqpebaco
drqpebaoc
drqpebcao
rbcdepqao
rbcdeqapo
rbcdeqpao
rbcdpeqao
rbcdpqaeo
rbcdpqaoe
rbcdpqeao
rbcdqaepo
rbcdqapeo
rbcdqapoe
rbcdqeapo
rbcdqepao
rbcdqpaeo
rbcdqpaoe
rbcdqpeao
rbcqadepo
rbcqadpeo
rbcqadpoe
rbcqdaepo
rbcqdapeo
rbcqdapoe
rbcqdeapo
rbcqdepao
rbcqdpaeo
rbcqdpaoe
rbcqdpeao
rbdcepqao
rbdceqapo
rbdceqpao
rbdcpeqao
rbdcpqaeo
rbdcpqaoe
rbdcpqeao
rbdcqaepo
rbdcqapeo
rbdcqapoe
rbdcqeapo
rbdcqepao
rbdcqpaeo
rbdcqpaoe
rbdcqpeao
rbdecpqao
rbdecqapo
rbdecqpao
rbdepcqao
rbdepqaco
rbdepqaoc
rbdepqcao
rbdeqacpo
rbdeqapco
rbdeqapoc
rbdeqcapo
rbdeqcpao
rbdeqpaco
rbdeqpaoc
rbdeqpcao
rbdpceqao
rbdpcqaeo
rbdpcqaoe
rbdpcqeao
rbdpecqao
rbdpeqaco
rbdpeqaoc
rbdpeqcao
rbdpqaceo
rbdpqacoe
rbdpqaeco
rbdpqaeoc
rbdpqaoce
rbdpqaoec
rbdpqcaeo
rbdpqcaoe
rbdpqceao
rbdpqeaco
rbdpqeaoc
rbdpqecao
rbdqacepo
rbdqacpeo
rbdqacpoe
rbdqaecpo
rbdqaepco
rbdqaepoc
rbdqapceo
rbdqapcoe
rbdqapeco
rbdqapeoc
rbdqapoce
rbdqapoec
rbdqcaepo
rbdqcapeo
rbdqcapoe
rbdqceapo
rbdqcepao
rbdqcpaeo
rbdqcpaoe
rbdqcpeao
rbdqeacpo
rbdqeapco
rbdqeapoc
rbdqecapo
rbdqecpao
rbdqepaco
rbdqepaoc
rbdqepcao
rbdqpaceo
rbdqpacoe
rbdqpaeco
rbdqpaeoc
rbdqpaoce
rbdqpaoec
rbdqpcaeo
rbdqpcaoe
rbdqpceao
rbdqpeaco
rbdqpeaoc
rbdqpecao
rbqacdepo
rbqacdpeo
rbqacdpoe
rbqadcepo
rbqadcpeo
rbqadcpoe
rbqadecpo
rbqadepco
rbqadepoc
rbqadpceo
rbqadpcoe
rbqadpeco
rbqadpeoc
rbqadpoce
rbqadpoec
rbqcadepo
rbqcadpeo
rbqcadpoe
rbqcdaepo
rbqcdapeo
rbqcdapoe
rbqcdeapo
rbqcdepao
rbqcdpaeo
rbqcdpaoe
rbqcdpeao
rbqdacepo
rbqdacpeo
rbqdacpoe
rbqdaecpo
rbqdaepco
rbqdaepoc
rbqdapceo
rbqdapcoe
rbqdapeco
rbqdapeoc
rbqdapoce
rbqdapoec
rbqdcaepo
rbqdcapeo
rbqdcapoe
rbqdceapo
rbqdcepao
rbqdcpaeo
rbqdcpaoe
rbqdcpeao
rbqdeacpo
rbqdeapco
rbqdeapoc
rbqdecapo
rbqdecpao
rbqdepaco
rbqdepaoc
rbqdepcao
rbqdpaceo
rbqdpacoe
rbqdpaeco
rbqdpaeoc
rbqdpaoce
rbqdpaoec
rbqdpcaeo
rbqdpcaoe
rbqdpceao
rbqdpeaco
rbqdpeaoc
rbqdpecao
rdbcepqao
rdbceqapo
rdbceqpao
rdbcpeqao
rdbcpqaeo
rdbcpqaoe
rdbcpqeao
rdbcqaepo
rdbcqapeo
rdbcqapoe
rdbcqeapo
rdbcqepao
rdbcqpaeo
rdbcqpaoe
rdbcqpeao
rdbecpqao
rdbecqapo
rdbecqpao
rdbepcqao
rdbepqaco
rdbepqaoc
rdbepqcao
rdbeqacpo
rdbeqapco
rdbeqapoc
rdbeqcapo
rdbeqcpao
rdbeqpaco
rdbeqpaoc
rdbeqpcao
rdbpceqao
rdbpcqaeo
rdbpcqaoe
rdbpcqeao
rdbpecqao
rdbpeqaco
rdbpeqaoc
rdbpeqcao
rdbpqaceo
rdbpqacoe
rdbpqaeco
rdbpqaeoc
rdbpqaoce
rdbpqaoec
rdbpqcaeo
rdbpqcaoe
rdbpqceao
rdbpqeaco
rdbpqeaoc
rdbpqecao
rdbqacepo
rdbqacpeo
rdbqacpoe
rdbqaecpo
rdbqaepco
rdbqaepoc
rdbqapceo
rdbqapcoe
rdbqapeco
rdbqapeoc
rdbqapoce
rdbqapoec
rdbqcaepo
rdbqcapeo
rdbqcapoe
rdbqceapo
rdbqcepao
rdbqcpaeo
rdbqcpaoe
rdbqcpeao
rdbqeacpo
rdbqeapco
rdbqeapoc
rdbqecapo
rdbqecpao
rdbqepaco
rdbqepaoc
rdbqepcao
rdbqpaceo
rdbqpacoe
rdbqpaeco
rdbqpaeoc
rdbqpaoce
rdbqpaoec
rdbqpcaeo
rdbqpcaoe
rdbqpceao
rdbqpeaco
rdbqpeaoc
rdbqpecao
rdebcpqao
rdebcqapo
rdebcqpao
rdebpcqao
rdebpqaco
rdebpqaoc
rdebpqcao
rdebqacpo
rdebqapco
rdebqapoc
rdebqcapo
rdebqcpao
rdebqpaco
rdebqpaoc
rdebqpcao
rdepbcqao
rdepbqaco
rdepbqaoc
rdepbqcao
rdepqabco
rdepqaboc
rdepqaobc
rdepqbaco
rdepqbaoc
rdepqbcao
rdeqabcpo
rdeqabpco
rdeqabpoc
rdeqapbco
rdeqapboc
rdeqapobc
rdeqbacpo
rdeqbapco
rdeqbapoc
rdeqbcapo
rdeqbcpao
rdeqbpaco
rdeqbpaoc
rdeqbpcao
rdeqpabco
rdeqpaboc
rdeqpaobc
rdeqpbaco
rdeqpbaoc
rdeqpbcao
rdpbceqao
rdpbcqaeo
rdpbcqaoe
rdpbcqeao
rdpbecqao
rdpbeqaco
rdpbeqaoc
rdpbeqcao
rdpbqaceo
rdpbqacoe
rdpbqaeco
rdpbqaeoc
rdpbqaoce
rdpbqaoec
rdpbqcaeo
rdpbqcaoe
rdpbqceao
rdpbqeaco
rdpbqeaoc
rdpbqecao
rdpebcqao
rdpebqaco
rdpebqaoc
rdpebqcao
rdpeqabco
rdpeqaboc
rdpeqaobc
rdpeqbaco
rdpeqbaoc
rdpeqbcao
rdpqabceo
rdpqabcoe
rdpqabeco
rdpqabeoc
rdpqaboce
rdpqaboec
rdpqaebco
rdpqaeboc
rdpqaeobc
rdpqaobce
rdpqaobec
rdpqaoebc
rdpqbaceo
rdpqbacoe
rdpqbaeco
rdpqbaeoc
rdpqbaoce
rdpqbaoec
rdpqbcaeo
rdpqbcaoe
rdpqbceao
rdpqbeaco
rdpqbeaoc
rdpqbecao
rdpqeabco
rdpqeaboc
rdpqeaobc
rdpqebaco
rdpqebaoc
rdpqebcao
rdqabcepo
rdqabcpeo
rdqabcpoe
rdqabecpo
rdqabepco
rdqabepoc
rdqabpceo
rdqabpcoe
rdqabpeco
rdqabpeoc
rdqabpoce
rdqabpoec
rdqaebcpo
rdqaebpco
rdqaebpoc
rdqaepbco
rdqaepboc
rdqaepobc
rdqapbceo
rdqapbcoe
rdqapbeco
rdqapbeoc
rdqapboce
rdqapboec
rdqapebco
rdqapeboc
rdqapeobc
rdqapobce
rdqapobec
rdqapoebc
rdqbacepo
rdqbacpeo
rdqbacpoe
rdqbaecpo
rdqbaepco
rdqbaepoc
rdqbapceo
rdqbapcoe
rdqbapeco
rdqbapeoc
rdqbapoce
rdqbapoec
rdqbcaepo
rdqbcapeo
rdqbcapoe
rdqbceapo
rdqbcepao
rdqbcpaeo
rdqbcpaoe
rdqbcpeao
rdqbeacpo
rdqbeapco
rdqbeapoc
rdqbecapo
rdqbecpao
rdqbepaco
rdqbepaoc
rdqbepcao
rdqbpaceo
rdqbpacoe
rdqbpaeco
rdqbpaeoc
rdqbpaoce
rdqbpaoec
rdqbpcaeo
rdqbpcaoe
rdqbpceao
rdqbpeaco
rdqbpeaoc
rdqbpecao
rdqeabcpo
rdqeabpco
rdqeabpoc
rdqeapbco
rdqeapboc
rdqeapobc
rdqebacpo
rdqebapco
rdqebapoc
rdqebcapo
rdqebcpao
rdqebpaco
rdqebpaoc
rdqebpcao
rdqepabco
rdqepaboc
rdqepaobc
rdqepbaco
rdqepbaoc
rdqepbcao
rdqpabceo
rdqpabcoe
rdqpabeco
rdqpabeoc
rdqpaboce
rdqpaboec
rdqpaebco
rdqpaeboc
rdqpaeobc
rdqpaobce
rdqpaobec
rdqpaoebc
rdqpbaceo
rdqpbacoe
rdqpbaeco
rdqpbaeoc
rdqpbaoce
rdqpbaoec
rdqpbcaeo
rdqpbcaoe
rdqpbceao
rdqpbeaco
rdqpbeaoc
rdqpbecao
rdqpeabco
rdqpeaboc
rdqpeaobc
rdqpebaco
rdqpebaoc
rdqpebcao
rqabcdepo
rqabcdpeo
rqabcdpoe
rqabdcepo
rqabdcpeo
rqabdcpoe
rqabdecpo
rqabdepco
rqabdepoc
rqabdpceo
rqabdpcoe
rqabdpeco
rqabdpeoc
rqabdpoce
rqabdpoec
rqadbcepo
rqadbcpeo
rqadbcpoe
rqadbecpo
rqadbepco
rqadbepoc
rqadbpceo
rqadbpcoe
rqadbpeco
rqadbpeoc
rqadbpoce
rqadbpoec
rqadebcpo
rqadebpco
rqadebpoc
rqadepbco
rqadepboc
rqadepobc
rqadpbceo
rqadpbcoe
rqadpbeco
rqadpbeoc
rqadpboce
rqadpboec
rqadpebco
rqadpeboc
rqadpeobc
rqadpobce
rqadpobec
rqadpoebc
rqbacdepo
rqbacdpeo
rqbacdpoe
rqbadcepo
rqbadcpeo
rqbadcpoe
rqbadecpo
rqbadepco
rqbadepoc
rqbadpceo
rqbadpcoe
rqbadpeco
rqbadpeoc
rqbadpoce
rqbadpoec
rqbcadepo
rqbcadpeo
rqbcadpoe
rqbcdaepo
rqbcdapeo
rqbcdapoe
rqbcdeapo
rqbcdepao
rqbcdpaeo
rqbcdpaoe
rqbcdpeao
rqbdacepo
rqbdacpeo
rqbdacpoe
rqbdaecpo
rqbdaepco
rqbdaepoc
rqbdapceo
rqbdapcoe
rqbdapeco
rqbdapeoc
rqbdapoce
rqbdapoec
rqbdcaepo
rqbdcapeo
rqbdcapoe
rqbdceapo
rqbdcepao
rqbdcpaeo
rqbdcpaoe
rqbdcpeao
rqbdeacpo
rqbdeapco
rqbdeapoc
rqbdecapo
rqbdecpao
rqbdepaco
rqbdepaoc
rqbdepcao
rqbdpaceo
rqbdpacoe
rqbdpaeco
rqbdpaeoc
rqbdpaoce
rqbdpaoec
rqbdpcaeo
rqbdpcaoe
rqbdpceao
rqbdpeaco
rqbdpeaoc
rqbdpecao
rqdabcepo
rqdabcpeo
rqdabcpoe
rqdabecpo
rqdabepco
rqdabepoc
rqdabpceo
rqdabpcoe
rqdabpeco
rqdabpeoc
rqdabpoce
rqdabpoec
rqdaebcpo
rqdaebpco
rqdaebpoc
rqdaepbco
rqdaepboc
rqdaepobc
rqdapbceo
rqdapbcoe
rqdapbeco
rqdapbeoc
rqdapboce
rqdapboec
rqdapebco
rqdapeboc
rqdapeobc
rqdapobce
rqdapobec
rqdapoebc
rqdbacepo
rqdbacpeo
rqdbacpoe
rqdbaecpo
rqdbaepco
rqdbaepoc
rqdbapceo
rqdbapcoe
rqdbapeco
rqdbapeoc
rqdbapoce
rqdbapoec
rqdbcaepo
rqdbcapeo
rqdbcapoe
rqdbceapo
rqdbcepao
rqdbcpaeo
rqdbcpaoe
rqdbcpeao
rqdbeacpo
rqdbeapco
rqdbeapoc
rqdbecapo
rqdbecpao
rqdbepaco
rqdbepaoc
rqdbepcao
rqdbpaceo
rqdbpacoe
rqdbpaeco
rqdbpaeoc
rqdbpaoce
rqdbpaoec
rqdbpcaeo
rqdbpcaoe
rqdbpceao
rqdbpeaco
rqdbpeaoc
rqdbpecao
rqdeabcpo
rqdeabpco
rqdeabpoc
rqdeapbco
rqdeapboc
rqdeapobc
rqdebacpo
rqdebapco
rqdebapoc
rqdebcapo
rqdebcpao
rqdebpaco
rqdebpaoc
rqdebpcao
rqdepabco
rqdepaboc
rqdepaobc
rqdepbaco
rqdepbaoc
rqdepbcao
rqdpabceo
rqdpabcoe
rqdpabeco
rqdpabeoc
rqdpaboce
rqdpaboec
rqdpaebco
rqdpaeboc
rqdpaeobc
rqdpaobce
rqdpaobec
rqdpaoebc
rqdpbaceo
rqdpbacoe
rqdpbaeco
rqdpbaeoc
rqdpbaoce
rqdpbaoec
rqdpbcaeo
rqdpbcaoe
rqdpbceao
rqdpbeaco
rqdpbeaoc
rqdpbecao
rqdpeabco
rqdpeaboc
rqdpeaobc
rqdpebaco
rqdpebaoc
rqdpebcao
Hope this helps. DON'T forget to print ALPHABETICALLY.

nguyenh3
New poster
Posts: 5
Joined: Mon Sep 20, 2010 5:53 pm

Re: 124 ....i don't know why WA

Post by nguyenh3 » Sun Oct 31, 2010 8:49 pm

In your input test case, you have "z a m n a q" which is invalid - variables cannot have the same name.

Shafaet_du
Experienced poster
Posts: 147
Joined: Mon Jun 07, 2010 11:43 am
Location: University Of Dhaka,Bangladesh
Contact:

Re: 124 ....i don't know why WA

Post by Shafaet_du » Sun Nov 07, 2010 4:56 pm

thanks for the correction

lorderico
New poster
Posts: 6
Joined: Sat Oct 02, 2010 10:47 pm

#124 Looking for test cases

Post by lorderico » Sun Sep 11, 2011 3:18 am

Hello, I am looking for some test cases for my wa code for 124 following orders. All other test cases I have found work on my code:

Code: Select all

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {

	public Main() {
		Scanner s = new Scanner(System.in);

		while(s.hasNext()){
			HashMap<Character,Node> nodes = new HashMap<Character,Node>();
			for(String c : s.nextLine().split(" ")){
				nodes.put(c.charAt(0), new Node(c.charAt(0)));
			}
			String[] ineq = s.nextLine().split(" ");
			if(ineq.length!=1){
				for(int i = 0; i < ineq.length; i+=2){
					nodes.get(ineq[i+1].charAt(0)).children.add(nodes.get(ineq[i].charAt(0)));
					nodes.get(ineq[i].charAt(0)).parents.add(nodes.get(ineq[i+1].charAt(0)));
				}
			}
			List<String> printedSoFar = new ArrayList<String>();
			print(nodes,"", printedSoFar);
			Collections.sort(printedSoFar);
			for(String ss : printedSoFar){
				System.out.println(ss);
			}
			System.out.println();
		}
	}

	void print(HashMap<Character, Node> nodes, String toPrint, List<String> printedSoFar){
		List<Character> chars = new ArrayList<Character>();
		for(Node n : nodes.values()){
			if(n.parents.size()==0 && !n.marked){
				chars.add(n.id);				
			}
		}
		if(chars.size()>0){
			for (char c : chars){
				Node chosen = nodes.get(c);
				chosen.marked = true;
				
				for(Node child : chosen.children){
					child.parents.remove(chosen);
				}
				
				print(nodes,c+toPrint,printedSoFar);
				
				for(Node child : chosen.children){
					child.parents.add(chosen);
				}
				chosen.marked = false;
			}
		}
		else{
			printedSoFar.add(toPrint);
		}
	}

	class Node{
		char id;
		boolean marked = false;
		HashSet<Node> children;
		HashSet<Node> parents;

		public Node(char id){
			this.id = id;
			children = new HashSet<Node>();
			parents = new HashSet<Node>();
		}

	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new Main();
	}

}
Thanks alot for the help,
Eric

Post Reply

Return to “Volume 1 (100-199)”