Page 2 of 3
Posted: Thu Jan 27, 2005 6:38 pm
by akiha
.. wrote:Similar mistake here:
char in[1000];
To hold a string of 1000 chars long, the array size should NOT be 1000.
BUT WHAT SHOULD THE ARRAY SIZE
THE PROGRAM HAVE NOT SPECIFIC THE ARRAY SIZE
AND ALSO I HAVE TRY SET IT TO 1000000
NO HELPS TO THE ERROR
Posted: Thu Jan 27, 2005 6:50 pm
by ..
Why do you say the array size isn't bounded by problem statement?
In your code, you want to use the array char in[] to store the word in input,
and it is given that "Each word contains at least two and at most 1000 lowercase characters".
http://appsrv.cse.cuhk.edu.hk/~csc1140/ ... _tuto2.ppt
Read page 8 again!!! You will know what the size of array char in[] should be.
In the code you have posted, I think there is no more bug. So you are making mistake in the remaining code. As I see your code you have posted, I can guess that you may make more mistake about array bound in the remaining code......
P.S. Don't you know that typing in full captial letters is impolite?
Posted: Thu Jan 27, 2005 7:08 pm
by akiha
FIRSLTY THZ ABOUT YOUR REPLY
>P.S. Don't you know that typing in full captial letters is impolite?
I DONT KNOW
WHY?
Posted: Thu Jan 27, 2005 7:18 pm
by ..
akiha wrote:FIRSLTY THZ ABOUT YOUR REPLY
>P.S. Don't you know that typing in full captial letters is impolite?
I DONT KNOW
WHY?
Well.....I can't find any reference about that, but it is a commonly known "web manner".
Write a word/sentence in captial means you want to emphasize the meaning of it. But writing the whole message in captial means you are shouting at me....
Posted: Thu Jan 27, 2005 7:22 pm
by akiha
so....I say sorry to you first
I just lazy to type caps lock XD
and
I just send the following code to acm
i return a segmentation error to me, too
Code: Select all
#include <stdio.h>
#include <string.h>
main(void)
{
char in[1001];
int head[26];
int tail[26];
int con[26][26];
int check[26];
int g[3];
int n=0;
int a,b,i,j,m,t,count,p,q;
int s=0;
int cb=0;
char prichk='0';
char secchk='0';
char terchk='0';
char finalchk='0';
char finalchk2='0';
char netio='0';
scanf ("%d\n" ,&t);
for (m=0;m<t;m++)
{
for (b=0;b<26;b++)
{
head[b]=0;
tail[b]=0;
check[b]=0;
}
printf("%d%d%d\n",head[26],tail[26],check[26]);
for (b=0;b<26;b++)
{
for (a=0;a<26;a++)
{
con[b][a]=0;
}
}
g[0]=-1;
g[1]=-1;
g[2]=0;
scanf ("%d\n" ,&s);
}
return 0;
}
Posted: Thu Jan 27, 2005 7:34 pm
by ..
1. This is NOT the code you just send to judge, I try submit it and get WA only.
2. Still bug here....
printf("%d%d%d\n",head[26],tail[26],check[26]);
3. About typing all captial letters:
http://www.dso.iastate.edu/dept/asc/ele ... uette.html
4. I think I should stop helping you debug here. Sad to say, I believe that you are too careless to solve this problem now......
10129 help!
Posted: Thu Jul 28, 2005 3:26 pm
by saatvik
I just needed some help on 10129.
if I understand corerctly I have to make a graph of all the 26 letters and then add a directed edge between the first letter and last letter of each word and then check for an eulerian path? is this correct.
also, i know how to check an eulerian path in an undirected graph but how do i do it in a directed graph? i know i have to check if it is strongly connected but how do i do that?
thanks
Posted: Wed Aug 24, 2005 12:13 pm
by polone
For every vertex in a directed gragh.
If indegree==outdegree and the gragh is strongly connected then there should exist euler cycles
Indegree means the number of ways(edges) into this vertex.
And out degree means out
But in this problem some times indegree!=outdegree
Result from the top and the bottom disks
as a detail..
--
We should thank for everyone on the board who helped us.
10129 ( plz give me some critical i\o)
Posted: Sat Apr 01, 2006 10:48 pm
by tuman
Re: 10129 ( plz give me some critical i\o)
Posted: Thu Aug 31, 2006 7:22 pm
by Sumon
Try This:
Input:
2
4
ad
da
pq
qp
4
ad
da
ad
da
Output:
The door cannot be opened.
Ordering is possible.
Posted: Wed Oct 18, 2006 12:34 am
by tuman
If any one is getting wrong answer in this problem then u might ve done the same mistake that i did.
i ve found my erra, it was an undirected graph but i thought it was directed.
Code: Select all
critical i/0
9
2
acm
ibm
3
acm
malform
mouse
2
ok
ok
3
ab
bc
ca
3
ab
bc
cb
1
ab
2
ab
bc
4
ab
ba
ab
ba
4
ab
ba
cd
dc
Output
The door cannot be opened.
Ordering is possible.
The door cannot be opened.
Ordering is possible.
Ordering is possible.
Ordering is possible.
Ordering is possible.
Ordering is possible.
The door cannot be opened.
Posted: Wed Apr 04, 2007 1:37 pm
by abdullah<cse du>
Hi,
I have submitted the problem for many times, but always get wrong answer. I have tested all the inputs which i have found in board and my program is ok for all given inputs. I can't find any wrong with my code. Please help me by locating errors.
My code:
Code: Select all
//Play on word-10129
#include<stdio.h>
#include<string.h>
#define TRUE 1
#define FALSE 0
char string[1008],
word[100008][4];
long test,i,j,num_word,p,q,flag;
int main(void)
{
scanf("%ld",&test);
for(i=0;i<test;i++)
{
scanf("%ld%*c",&num_word);
for(j=0;j<num_word;j++)
{
gets(string);
q=strlen(string)-1;
word[j][0]=string[0];
word[j][1]=string[q];
}
p=num_word-1;
flag=TRUE;
for(j=p;j>0;j--)
{
if(word[j][0]!=word[j-1][1])
{
flag=FALSE;
break;
}
}
if(flag==FALSE)
printf("The door cannot be opened.\n");
else
printf("Ordering is possible.\n");
}
return 0;
}
Please help me.
Thanks
ABDULLAH
Posted: Wed Apr 04, 2007 9:33 pm
by Jan
Your algorithm is totally wrong. Its an Euler Path problem. Generate cases yourself, it wouldnt be too hard.
10129(Wrong Answer)
Posted: Thu Jul 19, 2007 2:31 pm
by ishtiaq ahmed
I have tested all the inputs from the board but still facing WA. Can anybody help me? Please....
Code: Select all
#include<stdio.h>
#include<string.h>
char str[1000001],temp[1000001];
void main()
{
long x,i,tot,cas,j,flag;
scanf("%ld",&tot);
for(i=1;i<=tot;i++)
{
scanf("%ld",&cas);flag=0;
for(j=1;j<=cas;j++)
{
scanf("%s",str);
x=strlen(str);
temp[j]=str[x-1];
if(j>1 && flag==0)
{
if(str[0]!=temp[j-1])
flag=1;
}
}
if(flag==0)
printf("Ordering is possible.\n");
if(flag==1)
printf("The door cannot be opened.\n");
}
}
Posted: Thu Jul 19, 2007 3:08 pm
by helloneo
Try this case..
My output is..