10129 - Play on Words

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

Moderator: Board moderators

akiha
New poster
Posts: 7
Joined: Sat Jan 22, 2005 6:43 pm

Post 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

..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Post 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?
My signature:
  • Please make discussion about the algorithm BRFORE posting source code.
    We can learn much more in discussion than reading source code.
  • I HATE testing account.
  • Don't send me source code for debug.

akiha
New poster
Posts: 7
Joined: Sat Jan 22, 2005 6:43 pm

Post 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?

..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Post 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....
My signature:
  • Please make discussion about the algorithm BRFORE posting source code.
    We can learn much more in discussion than reading source code.
  • I HATE testing account.
  • Don't send me source code for debug.

akiha
New poster
Posts: 7
Joined: Sat Jan 22, 2005 6:43 pm

Post 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;
}

..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Post 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......
My signature:
  • Please make discussion about the algorithm BRFORE posting source code.
    We can learn much more in discussion than reading source code.
  • I HATE testing account.
  • Don't send me source code for debug.

saatvik
New poster
Posts: 3
Joined: Thu Jul 28, 2005 3:22 pm

10129 help!

Post 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

polone
New poster
Posts: 43
Joined: Sun May 08, 2005 2:31 am
Location: Taiwan

Post 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.

tuman
New poster
Posts: 24
Joined: Sat Oct 22, 2005 7:30 pm
Location: CUET
Contact:

10129 ( plz give me some critical i\o)

Post by tuman »

I badly need some input-output for the problem PLAY on WORDS its a simple Euler path problem but i cant do anything unless i experience some critical input and output.

:( :( :( :( :(
We the dreamer of the dreamy dream...

Sumon
New poster
Posts: 17
Joined: Fri May 30, 2003 8:14 pm
Location: Bangladesh
Contact:

Re: 10129 ( plz give me some critical i\o)

Post by Sumon »

tuman wrote:I badly need some input-output for the problem PLAY on WORDS its a simple Euler path problem but i cant do anything unless i experience some critical input and output.

:( :( :( :( :(
Try This:

Input:
2
4
ad
da
pq
qp
4
ad
da
ad
da

Output:
The door cannot be opened.
Ordering is possible.
Change your view,your life will be changed.

tuman
New poster
Posts: 24
Joined: Sat Oct 22, 2005 7:30 pm
Location: CUET
Contact:

Post 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.

We the dreamer of the dreamy dream...

abdullah<cse du>
New poster
Posts: 39
Joined: Mon Dec 04, 2006 2:18 pm
Location: Bangladesh(CSE DU)
Contact:

Post 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

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Your algorithm is totally wrong. Its an Euler Path problem. Generate cases yourself, it wouldnt be too hard.
Ami ekhono shopno dekhi...
HomePage

ishtiaq ahmed
Learning poster
Posts: 53
Joined: Sat Jul 29, 2006 7:33 am
Location: (CSE,DU), Dhaka,Bangladesh

10129(Wrong Answer)

Post 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");
	}
}
No venture no gain

with best regards
------------------------
ishtiaq ahmed

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo »

Try this case..

Code: Select all

1
3
abc
bcd
cbb
My output is..

Code: Select all

Ordering is possible.

Post Reply

Return to “Volume 101 (10100-10199)”