10050 - Hartals

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

Moderator: Board moderators

Fuad Hassan_IIUC(DC)
New poster
Posts: 18
Joined: Fri Jan 07, 2005 9:35 pm
Location: Bangladesh

10050 still WA?

Post by Fuad Hassan_IIUC(DC) »

i have changed a bit the initialization part but still WA
Last edited by Fuad Hassan_IIUC(DC) on Tue Feb 01, 2005 2:57 pm, edited 1 time in total.
fuad
Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Post by Observer »

Please do not open a new topic for posts concerning the same problem.

And you have completely mistaken my previous reply... By initialization I mean setting the elements of your array count_a to 0. Check that statement, and hope you can get that fixed.

P.S. Remember to remove your code after you get AC. 8)
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Fuad Hassan_IIUC(DC)
New poster
Posts: 18
Joined: Fri Jan 07, 2005 9:35 pm
Location: Bangladesh

Post by Fuad Hassan_IIUC(DC) »

I don't understand what did you want to mean. plz describe it by pointing the specific line. thank you very much. :roll:
fuad
Fuad Hassan_IIUC(DC)
New poster
Posts: 18
Joined: Fri Jan 07, 2005 9:35 pm
Location: Bangladesh

Post by Fuad Hassan_IIUC(DC) »

thank you veeeeeeeeeeeeeery much i got AC :D thank you again.
fuad
Salman
New poster
Posts: 25
Joined: Thu Jun 26, 2003 9:45 am

10050

Post by Salman »

HI,

Getting WA for this code



[code]
/*
Name: Hartals
Number: 10050
Type : ad hoc
Process : ON
Author :Salman Zaman
Email : zamansalman@gmail.com
Date : 02/06/05 01:27


*/



#include<stdio.h>
//#include<string.h>



//#include<conio.h>



int main(){


int n,p,t;
int days[4000];
int party[500];
int i,j,k,x,count;

//freopen("10050.txt","r",stdin);

scanf("%d",&t);
for(i=0;i<t;i++){
scanf("%d%d",&n,&p);
for(k=0;k<=n;k++)days[k]=0;
for(j=0;j<p;j++){
scanf("%d",&x);
for(k=x;k<=n;k=k+x){
days[k]=1;
}
}
for(k=7;k<=n;k+=7){
days[k]=0;
days[k-1]=0;
}
for(k=1,count=0;k<=n;k++){
if(days[k])count++;
}
printf("%d\n",count);

}


// getch();
return 0;
}
[/code]

Test case is ok but i think the problem is with weekends checking!!!
J&Jewel
New poster
Posts: 50
Joined: Thu Jul 31, 2003 10:43 am
Location: Daffodil University,Dhaka,Bangladesh
Contact:

Post by J&Jewel »

U used a array party that is never used.... & try for these inputs:
Input:
4
8
100
4
12
15
25
40
1000
4
45
100
6
12
3000
10
15
500
6
89
87
184
456
15
444
2
My Acc program Output:
5
15
132
1166
Your:
5
15
133
1166
So may be u have done some mistake ....Try urself ...best..to find out it...
I hate Wrong Answer!
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

test cases

Post by Sedefcho »

J & Jewel,

I'm affraid your input is slightly wrong
( does dot match the input description from
the problem statement ).

Here are your test cases corrected plus
one more test case.


INPUT

Code: Select all

5 
14 
3 
3 
4 
8 
100 
4 
12 
15 
25 
40 
1000 
4 
45 
100 
6 
12 
3000 
10 
15 
500 
6 
89 
87 
184 
456 
15 
444 
2
3600
10
9
12
17
100
121
130
200
3600
3601
181

OUTPUT

Code: Select all

5
15
132
1166
610
I hope the test cases will be helpful to
Salman and/or to someone else.
J&Jewel
New poster
Posts: 50
Joined: Thu Jul 31, 2003 10:43 am
Location: Daffodil University,Dhaka,Bangladesh
Contact:

Post by J&Jewel »

Sorry salman and thanks to sadefcho ...may be 4 copy paste problem happends....
I hate Wrong Answer!
mosaick2
New poster
Posts: 21
Joined: Wed Mar 08, 2006 4:05 am

10050 - Hartals - I got RE.

Post by mosaick2 »

I don't know what make my program runtime error.
Actually, when I tested my program, it was no problem.
Who can advise me?

Code: Select all

#include <iostream>
#include <cstring>
using namespace std;
const int MAXPARTY = 110;
const int MAXDAY = 3700;
const int SAT = 7;

int main()
{
	int tscase;
	cin >> tscase;
	int days, partis;
	bool day[MAXDAY] = {false,};
	int party[MAXPARTY] = {0,};
	for(int i=0; i < tscase; i++)
	{
		// Input
		cin >> days >> partis;		
		for(int j=0; j < partis; j++)
		{
			cin >> party[j];
		}
		// Processing
		for(int k=1; k <= days; k++)
		{
			for(int m=0; m < partis; m++)
			{
				if( (k % party[m]) == 0 ) {
					day[k] = true;					
				}
			}
		}
		int count = 0;
		for(int k=1; k <= days; k++)
		{
			if( (day[k] == true) ) {
				if( (k % SAT) != 0 && (k % SAT) != 6) {
					count++;
				}
			}
		}
		// Output
		if( i == tscase-1 )
			cout << count;
		else
			cout << count << endl;

		// Clear 
		memset(day, 0x00, sizeof(int)*days);
		memset(party, 0x00, sizeof(int)*partis);
	}

	return 0;
}
mosaick2
New poster
Posts: 21
Joined: Wed Mar 08, 2006 4:05 am

Re: 10050 - Hartals - I got RE.

Post by mosaick2 »

I got A.C.
But, I have just changed my Clear part.
I used for-loop to clear array instead of memset function.
I can't understand why the memset function occur Runtime error.
Who can explain me about it?
kryptolus
New poster
Posts: 16
Joined: Sun Mar 19, 2006 9:36 am
Location: New York

Re: 10050 - Hartals - I got RE.

Post by kryptolus »

mosaick2 wrote:I got A.C.
But, I have just changed my Clear part.
I used for-loop to clear array instead of memset function.
I can't understand why the memset function occur Runtime error.
Who can explain me about it?
You define 'day' as an array of bools yet you use sizeof(int) instead of sizeof(bool) when you specify the size of the array in memset. 'bool' is defined as a char so you are clearing data after the end of your array.
mosaick2
New poster
Posts: 21
Joined: Wed Mar 08, 2006 4:05 am

Re: 10050 - Hartals - I got RE.

Post by mosaick2 »

kryptolus wrote:
mosaick2 wrote:I got A.C.
But, I have just changed my Clear part.
I used for-loop to clear array instead of memset function.
I can't understand why the memset function occur Runtime error.
Who can explain me about it?
You define 'day' as an array of bools yet you use sizeof(int) instead of sizeof(bool) when you specify the size of the array in memset. 'bool' is defined as a char so you are clearing data after the end of your array.

Oh, my GOD...
Thanks, kruptolus.
I'm really appreciate you.
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

why runtime error hartals:10050?

Post by newton »

deleted after acceptation





thank you to help me.
Last edited by newton on Wed Dec 20, 2006 8:26 am, edited 1 time in total.
tan_Yui
Experienced poster
Posts: 155
Joined: Sat Jul 10, 2004 12:41 am

Re: why runtime error hartals:10050?

Post by tan_Yui »

newton wrote:may you check it please?
both of c and c++ compiler told me runtime error.
but why?
array[1000] -> array[3651]
day[3651] -> day[100]

After getting correct answer, please delete above your code.

Best regards.
Ion2Atom
New poster
Posts: 3
Joined: Mon Sep 25, 2006 9:41 pm

What am I doing wrong?

Post by Ion2Atom »

I have tried my program with all the sample input from the four threads on Hartals and it works perfectly for all of them. What am I missing? Thanks in advance.

Code: Select all

Figured out my problem.
Post Reply

Return to “Volume 100 (10000-10099)”