300 - Maya Calendar

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

Moderator: Board moderators

Sakib
New poster
Posts: 24
Joined: Fri Jan 28, 2005 5:27 pm
Location: Bangladesh

Post by Sakib »

yes u r right.

The last month is uayet.

the output of the last input (4. uayet 4999) should be ----------

11 ok 7018 ? isn,t it ?

the outputs are same with yours for the rest.

but WA!!!!!!

i have read other posts , but cant make it ok.
should i post my code ?
/* Sorry For Nothing */

Sakib
New poster
Posts: 24
Joined: Fri Jan 28, 2005 5:27 pm
Location: Bangladesh

Post by Sakib »

Here is my code.
Please help me.

Code: Select all


Cut After ACC!

Mamun bhai thanks for helping in advance. :D
Last edited by Sakib on Sat Nov 26, 2005 5:33 am, edited 1 time in total.
/* Sorry For Nothing */

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Location: Bangladesh
Contact:

Post by mamun »

I don't know why you wrote the following line in main()

Code: Select all

if(j == 18)j = j * 5;
Remove it. Let it be just

Code: Select all

j = j * 20;

Sakib
New poster
Posts: 24
Joined: Fri Jan 28, 2005 5:27 pm
Location: Bangladesh

Post by Sakib »

ACC now!

But i thought the last month has only five days.

so at the last case i wanted to count 5.
in other case it is 20.

please explain.

and many many thanks again.
/* Sorry For Nothing */

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Location: Bangladesh
Contact:

Post by mamun »

Sakib wrote:ACC now!

But i thought the last month has only five days.

so at the last case i wanted to count 5.
in other case it is 20.

please explain.

and many many thanks again.
When you count total number of days you are actually counting how many days are there prior to the beginning of the current month plus the number of days of current month. Note that you return 0 for the first month. So for last month you calculate total number of days before this month (all 20 days) plus number of days of this month.

Sakib
New poster
Posts: 24
Joined: Fri Jan 28, 2005 5:27 pm
Location: Bangladesh

Post by Sakib »

Thanks Mamun Bhai.

I am totally clear now.
/* Sorry For Nothing */

IRA
Learning poster
Posts: 82
Joined: Sat Jan 07, 2006 6:52 am

300 WA

Post by IRA »

Why do I got WA?
I need some input data and output data to test my program
Please,help!.....

Code: Select all

#include <cstdio>
#include <cstring>

char *Haab[]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char *Tzolkin[]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};

int main()
{
	int num,i;
	int day,year,total,s,k;
	char month[20];

	scanf("%d",&num);
	printf("%d\n",num);
	while(num--)
	{
		scanf("%d. %s %d",&day,month,&year);
		for(i=0;i<=18;i++)
			if(!strcmp(month,Haab[i]))
				break;
		total=i*20+day+1+year*365;
		//total=20;
		s=(total%20==0)?20:total%20;
		//printf("[%d]\n",total);
		printf("%d %s %d\n",(total%13==0)?13:total%13,Tzolkin[s-1],total/260);
	}
	return 0;
}

Raiyan Kamal
Experienced poster
Posts: 106
Joined: Thu Jan 29, 2004 12:07 pm
Location: Bangladesh
Contact:

Post by Raiyan Kamal »

a previous post on this problem :
http://online-judge.uva.es/board/viewtopic.php?t=5131

another ( with a good debugging idea ) :
http://online-judge.uva.es/board/viewtopic.php?t=5989

hope it helps

farzane
New poster
Posts: 26
Joined: Thu Jun 15, 2006 9:26 am

300 WA

Post by farzane »

could any one please tell me why got WA on this code:

#include<string.h>
//#include<fstream.h>
#include<iostream.h>

void main(){
// ofstream cout("f:\\my300.out");
// ifstream cin("f:\\300.in");
char habmons[20][10]={
"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh",
"mac","kankin","muan","pax","koyab","cumhu","uayet"};

char tzolkinname[20][10]={"ahau","imix","ik","akbal","kan","chicchan","cimi","manik","lamat",
"muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac"};

long long i,n,year,k,j,day,finaladad,adadperyod,finalyear,mon,mazrab;
char peryod[10],s[10],habmon[10]
;
cin>>n;
cout<<n<<endl;
for(i=0;i<n;i++){
cin>>s;
cin>>habmon;
cin>>year;
for(k=0;k<20;k++)
if(strcmp(habmon,habmons[k])==0){
mon=k;
break;
}

day=mazrab=1;
for(j=strlen(s)-2;j>=0;j--){

day=day+(s[j]-'0')*mazrab;
mazrab*=10;
}
day+=20*mon;
day+=365*year;

finalyear=day/260;
day=day%260;
finaladad=day%13;
if(finaladad==0)finaladad=13;//else finaladad++;
// adadperyod=day;
strcpy(peryod,tzolkinname[day%20]);
cout<<finaladad<<" "<<peryod<<" "<<finalyear<<endl;
}
}

Raiyan Kamal
Experienced poster
Posts: 106
Joined: Thu Jan 29, 2004 12:07 pm
Location: Bangladesh
Contact:

Post by Raiyan Kamal »

a previous post on this problem :
http://online-judge.uva.es/board/viewtopic.php?t=5131

another ( with a good debugging idea ) :
http://online-judge.uva.es/board/viewtopic.php?t=5989

hope it helps

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Location: Calgary, Canada

Post by Darko »

I didn't check thouroughly, but I solved it this week, so - what does this do?:

Code: Select all

if(finaladad==0)finaladad=13;//else finaladad++;
first day is 1, not 13, not sure if you are gettigng right answers for the sample input
why not just

Code: Select all

finaladad=(day%13)+1;

vijay03
New poster
Posts: 33
Joined: Wed Sep 13, 2006 6:46 pm
Contact:

300- CE

Post by vijay03 »

I submitted the following code in OJ and got compiler error:

Code: Select all

Removed after ACC
The above code compiles on vc++ and gives the correct answer. And in general, what is the source of CEs on OJ?
Last edited by vijay03 on Wed Sep 20, 2006 12:41 pm, edited 1 time in total.

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf »

I submitted your code as C++, and it has been succesfully compiled.

Did you submit it as a C source? C doesn't have things like "int &d", "int &ny".

vijay03
New poster
Posts: 33
Joined: Wed Sep 13, 2006 6:46 pm
Contact:

why WA?

Post by vijay03 »

I submitted it as C++ and it resulted in WA! As far i know, the logic is correct and gives the correct output for all the inputs i gave.. Do i need to change the code so that all the c functions are changed into c++? I thought c++ supported all the c functions..

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf »

There are errors in your lists of names.
For example, you have two "pop" (p[0] and p[15]), and some names are in a wrong order.

Also, instead of all this lengthy strcpy stuff, you can initilialize lists simply with:

Code: Select all

char p[19][10]={"pop","no","zip","zotz",.....};

Post Reply

Return to “Volume 3 (300-399)”