Page 1 of 5
300 - Maya Calendar
Posted: Sun Apr 28, 2002 4:12 pm
by C8H10N4O2
This works for all my test cases. Anyone know of any special tricks to this problem?
[cpp]#include <cstdio>
#include <cstring>
int ResolveMonth (char P[100])
{
char X[19][10]={"pop","no","zip","zotz","tzec","xul",
"yoxkin","mol","chen","yax","zac","ceh",
"mac","kankin","muan","pax","koyab","cumhu",
"uayet"};
int i;
for(i=0;i<19;i++)
{
if(strcmp(P,X)==0)
return i;
}
return -1;
}
void main()
{
int i,j,k,N,n,d,y;
char M[100];
char X[20][10]={"imix","ik","akbal","kan","chicchan",
"cimi","manik","lamat","muluk","ok",
"chuen","eb","ben","ix","mem","cib",
"caban","eznab","canac","ahau"};
scanf("%d",&N);
for(n=0;n<N;n++)
{
scanf("%d.%s%d",&d,&M,&y);
d+=ResolveMonth(M)*20+y*365;
y=d/260;
d%=260;
strcpy(M,X[d%20]);
d%=13;
d++;
printf("%d %s %d\n",d,M,y);
}
}[/cpp]
Posted: Mon Apr 29, 2002 2:11 am
by wyvmak
oh, after a few minutes of inspection, you need to add this line after "scanf("%d",&N);":
printf("%d\n",N);
Posted: Mon Apr 29, 2002 12:28 pm
by C8H10N4O2
Ah ha! Thank you. Sometimes the simplest details can get you:)
300
Posted: Tue May 28, 2002 9:27 pm
by dabendan
I got wrong answer.
I can't find the wrong.
[c]#include <stdio.h>
#include <string.h>
long int mon,day,year;
long now;
int main()
{
char b[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int n;
int index;
void Input();
scanf("%d",&n);
printf("%d\n",n);
for(index=0;index<n;index++){
Input();
now=year*365+mon*20+day;
printf("%ld %s %ld\n",now%13+1,b[now%20],now/260);
}
return(0);
}
void Input()
{
char a[19][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char str[10];
int index;
scanf("%ld. %s %ld",&day,str,&year);
for(index=0;index<19;index++)
{
if(strcmp(str,a[index])==0)
{
mon=index;
break;
}
}
}[/c]
Hi!
Posted: Wed May 29, 2002 4:49 pm
by cyfra
Hmm...
There is nothing wrong..
I got your program Accepted without any changes...
Try to change your e-mail client (I use Bat)
Good Luck

?!
Posted: Wed May 29, 2002 6:41 pm
by dabendan
That's strange.
I copied my code from here and sent it then I got accept.
But when I sent it from my file then I got wrong answer.
I couldn't find any differences.

Posted: Thu May 30, 2002 12:40 am
by Stefan Pochmann
Compare the "we got your program" automatic response emails you got back from the judge. They should contain the program as the judge got it.
Do they differ?
Note that I actually expect an answer, just like the dozen times before when I asked this question and nobody ever was kind enough to answer.
Posted: Thu May 30, 2002 7:29 am
by dabendan
When I copied my codes from file to Outlook Express 5.
It cut my code like that:
[c]#include <stdio.h>
#include <string.h>
long int mon,day,year;
long now;
int main()
{
char
b[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","mulu
k","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int n;
int index;
void Input();
scanf("%d",&n);
printf("%d\n",n);
for(index=0;index<n;index++){
Input();
now=year*365+mon*20+day;
printf("%ld %s %ld\n",now%13+1,b[now%20],now/260);
}
return(0);
}
void Input()
{
char
a[19][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax",
"zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char str[10];
int index;
scanf("%ld. %s %ld",&day,str,&year);
for(index=0;index<19;index++)
{
if(strcmp(str,a[index])==0)
{
mon=index;
break;
}
}
}[/c]
Posted: Thu Jun 20, 2002 3:35 pm
by cyfra
Yes this is the problem in Outlook...
It cuts lines in many places (you can propably change it in options)
and in the middle of your string there is a sign and you get W.A.
but on your place I would check twice before sending if some lines are cut (or change mail client

..
Good Luck

300-RE
Posted: Fri Jan 03, 2003 11:05 am
by gracia
can you tell me why i've got runtime error: invalid memory reference
plzzzzz....
Posted: Sat May 10, 2003 7:20 am
by ezra
try to large your array , good luck!
Posted: Sun May 11, 2003 11:49 am
by szymcio2001
I had RE because I forgot to copy the name of the last month "uayet" to the const array in a source code. The name of it is written few lines below other names in the problem description and this was the cause of my mistake. Maybe you have the similar error.
Good luck!
Szymcio
WA 300
Posted: Thu Jun 19, 2003 8:12 pm
by reza ali
I think my program is write. Please anybody, check my code.If there is important input you have, send it. Below the code://@begin_of_source_code
#include<iostream.h>
#include<string.h>
int main()
{
/*@JUDGE_ID: ----------- 300 C++ "Dynamic programming" */
unsigned long total;
int n,count,day,year,i,tmonth,dayname,tyear;
char dot,month[10],haab[19][10],tzolkin[20][10];
strcpy(haab[0],"pop");
strcpy(haab[1],"no");
strcpy(haab[2],"zip");
strcpy(haab[3],"zotz");
strcpy(haab[4],"tzec");
strcpy(haab[5],"xul");
strcpy(haab[6],"yoxkin");
strcpy(haab[7],"mol");
strcpy(haab[8],"chen");
strcpy(haab[9],"yax");
strcpy(haab[10],"zac");
strcpy(haab[11],"ceh");
strcpy(haab[12],"mac");
strcpy(haab[13],"kankin");
strcpy(haab[14],"muan");
strcpy(haab[15],"pax");
strcpy(haab[16],"koyab");
strcpy(haab[17],"cumhu");
strcpy(haab[18],"uayet");
strcpy(tzolkin[0],"imix");
strcpy(tzolkin[1],"ik");
strcpy(tzolkin[2],"akbal");
strcpy(tzolkin[3],"kan");
strcpy(tzolkin[4],"chicchan");
strcpy(tzolkin[5],"cimi");
strcpy(tzolkin[6],"manik");
strcpy(tzolkin[7],"lamat");
strcpy(tzolkin[8],"muluk");
strcpy(tzolkin[9],"ok");
strcpy(tzolkin[10],"chuen");
strcpy(tzolkin[11],"eb");
strcpy(tzolkin[12],"ben");
strcpy(tzolkin[13],"ix");
strcpy(tzolkin[14],"mem");
strcpy(tzolkin[15],"cib");
strcpy(tzolkin[16],"caban");
strcpy(tzolkin[17],"eznab");
strcpy(tzolkin[18],"canac");
strcpy(tzolkin[19],"ahau");
while(cin>>n)
{
if (n==0) break;
cout<<n<<endl;
count=0;
while(count++<n)
{
cin>>day>>dot>>month>>year;
if(year>=5000) {cout<<"out of limit";break;}
if(day>19) {cout<<"out of limit";break;}
if(strcmp(month,"uayet")==0) { if(day>4) {cout<<"out of limit";break;}}
for(i=0;i<=18;i++)
{
if(strcmp(month,haab)==0)
{
total=(unsigned long) day+1+(unsigned long)i*20+365*(unsigned long)year;
break;
}
}
if(total>259) tyear=(total/260);
else tyear=0;
total=total%260;
tmonth=total%13; if(tmonth==0) tmonth=13;
dayname=total%20; if(dayname==0) dayname=20;
cout<<tmonth<<" "<<tzolkin[dayname-1]<<" "<<tyear<<endl;
}
}
return 0;
}
//@end_of_source_code
Posted: Fri Jun 20, 2003 8:15 pm
by Pupirev Sergei
Your counting of tmonth and dayname are wrong!
This code got AC:))
#include<iostream.h>
#include<string.h>
int main()
{
/*@JUDGE_ID: ----------- 300 C++ "Dynamic programming" */
unsigned long total;
int n,count,day,year,i,tmonth,dayname,tyear;
char dot,month[10],haab[19][10],tzolkin[20][10];
strcpy(haab[0],"pop");
strcpy(haab[1],"no");
strcpy(haab[2],"zip");
strcpy(haab[3],"zotz");
strcpy(haab[4],"tzec");
strcpy(haab[5],"xul");
strcpy(haab[6],"yoxkin");
strcpy(haab[7],"mol");
strcpy(haab[8],"chen");
strcpy(haab[9],"yax");
strcpy(haab[10],"zac");
strcpy(haab[11],"ceh");
strcpy(haab[12],"mac");
strcpy(haab[13],"kankin");
strcpy(haab[14],"muan");
strcpy(haab[15],"pax");
strcpy(haab[16],"koyab");
strcpy(haab[17],"cumhu");
strcpy(haab[18],"uayet");
strcpy(tzolkin[0],"imix");
strcpy(tzolkin[1],"ik");
strcpy(tzolkin[2],"akbal");
strcpy(tzolkin[3],"kan");
strcpy(tzolkin[4],"chicchan");
strcpy(tzolkin[5],"cimi");
strcpy(tzolkin[6],"manik");
strcpy(tzolkin[7],"lamat");
strcpy(tzolkin[8],"muluk");
strcpy(tzolkin[9],"ok");
strcpy(tzolkin[10],"chuen");
strcpy(tzolkin[11],"eb");
strcpy(tzolkin[12],"ben");
strcpy(tzolkin[13],"ix");
strcpy(tzolkin[14],"mem");
strcpy(tzolkin[15],"cib");
strcpy(tzolkin[16],"caban");
strcpy(tzolkin[17],"eznab");
strcpy(tzolkin[18],"canac");
strcpy(tzolkin[19],"ahau");
while(cin>>n)
{
if (n==0) break;
cout<<n<<endl;
count=0;
while(count++<n)
{
cin>>day>>dot>>month>>year;
if(year>5000) {cout<<"out of limit";break;}
if(day>19) {cout<<"out of limit";break;}
if(strcmp(month,"uayet")==0) { if(day>4) {cout<<"out of limit";break;}}
for(i=0;i<=18;i++)
{
if(strcmp(month,haab)==0)
{
total=(unsigned long) day+(unsigned long)i*20+365*(unsigned long)year;
break;
}
}
if(total>259) tyear=(total/260);
//else tyear=0;
total=total%260;
tmonth=total%13+1; //if(tmonth==0) tmonth=13;
dayname=total%20; //if(dayname==0) dayname=20;
cout<<tmonth<<" "<<tzolkin[dayname]<<" "<<tyear<<endl;
}
}
return 0;
}
300 AC(PE)
Posted: Sun Jun 22, 2003 8:15 pm
by reza ali
Mr. pupirev,
This is surprising that my code is presentation error.There is also your code which is Accepted.Tell me the difference.The codes are below:
//@begin_of_source_code
#include<iostream.h>
#include<string.h>
int main()
{
/*@JUDGE_ID: --------------- 300 C++ "Dynamic programming" */
unsigned long total;
int n,count,day,year,i,tmonth,dayname,tyear;
char dot,month[10],haab[19][10],tzolkin[20][10];
strcpy(haab[0],"pop");
strcpy(haab[1],"no");
strcpy(haab[2],"zip");
strcpy(haab[3],"zotz");
strcpy(haab[4],"tzec");
strcpy(haab[5],"xul");
strcpy(haab[6],"yoxkin");
strcpy(haab[7],"mol");
strcpy(haab[8],"chen");
strcpy(haab[9],"yax");
strcpy(haab[10],"zac");
strcpy(haab[11],"ceh");
strcpy(haab[12],"mac");
strcpy(haab[13],"kankin");
strcpy(haab[14],"muan");
strcpy(haab[15],"pax");
strcpy(haab[16],"koyab");
strcpy(haab[17],"cumhu");
strcpy(haab[18],"uayet");
strcpy(tzolkin[0],"imix");
strcpy(tzolkin[1],"ik");
strcpy(tzolkin[2],"akbal");
strcpy(tzolkin[3],"kan");
strcpy(tzolkin[4],"chicchan");
strcpy(tzolkin[5],"cimi");
strcpy(tzolkin[6],"manik");
strcpy(tzolkin[7],"lamat");
strcpy(tzolkin[8],"muluk");
strcpy(tzolkin[9],"ok");
strcpy(tzolkin[10],"chuen");
strcpy(tzolkin[11],"eb");
strcpy(tzolkin[12],"ben");
strcpy(tzolkin[13],"ix");
strcpy(tzolkin[14],"mem");
strcpy(tzolkin[15],"cib");
strcpy(tzolkin[16],"caban");
strcpy(tzolkin[17],"eznab");
strcpy(tzolkin[18],"canac");
strcpy(tzolkin[19],"ahau");
while(cin>>n)
{
if (n==0) break;
/*count=0;
while(count++<n)
{
cin>>day[count]>>dot>>month[count]>>year[count];
}*/
cout<<n<<endl;
count=0;
while(count++<n)
{
cin>>day>>dot>>month>>year;
if(year>=5000) {cout<<"out of limit";break;}
if(day>19) {cout<<"out of limit";break;}
if(strcmp(month,"uayet")==0) { if(day>4) {cout<<"out of limit";break;}}
for(i=0;i<=18;i++)
{
if(strcmp(month,haab)==0)
{
total=(unsigned long) day+1+(unsigned long)i*20+365*(unsigned long)year;
break;
}
}
if(total%260==0) tyear=(total/260)-1;
else tyear=total/260;
total=total%260;
tmonth=total%13; if(tmonth==0) tmonth=13;
dayname=total%20; if(dayname==0) dayname=20;
cout<<tmonth<<" "<<tzolkin[dayname-1]<<" "<<tyear<<endl;
}
}
return 0;
}
//@end_of_source_code
BUT THE CODE BELOW IS ACCEPTED.PLEASE TELL ME WHY?
#include<iostream.h>
#include<string.h>
int main()
{
/*@JUDGE_ID: ----------- 300 C++ "Dynamic programming" */
unsigned long total;
int n,count,day,year,i,tmonth,dayname,tyear;
char dot,month[10],haab[19][10],tzolkin[20][10];
strcpy(haab[0],"pop");
strcpy(haab[1],"no");
strcpy(haab[2],"zip");
strcpy(haab[3],"zotz");
strcpy(haab[4],"tzec");
strcpy(haab[5],"xul");
strcpy(haab[6],"yoxkin");
strcpy(haab[7],"mol");
strcpy(haab[8],"chen");
strcpy(haab[9],"yax");
strcpy(haab[10],"zac");
strcpy(haab[11],"ceh");
strcpy(haab[12],"mac");
strcpy(haab[13],"kankin");
strcpy(haab[14],"muan");
strcpy(haab[15],"pax");
strcpy(haab[16],"koyab");
strcpy(haab[17],"cumhu");
strcpy(haab[18],"uayet");
strcpy(tzolkin[0],"imix");
strcpy(tzolkin[1],"ik");
strcpy(tzolkin[2],"akbal");
strcpy(tzolkin[3],"kan");
strcpy(tzolkin[4],"chicchan");
strcpy(tzolkin[5],"cimi");
strcpy(tzolkin[6],"manik");
strcpy(tzolkin[7],"lamat");
strcpy(tzolkin[8],"muluk");
strcpy(tzolkin[9],"ok");
strcpy(tzolkin[10],"chuen");
strcpy(tzolkin[11],"eb");
strcpy(tzolkin[12],"ben");
strcpy(tzolkin[13],"ix");
strcpy(tzolkin[14],"mem");
strcpy(tzolkin[15],"cib");
strcpy(tzolkin[16],"caban");
strcpy(tzolkin[17],"eznab");
strcpy(tzolkin[18],"canac");
strcpy(tzolkin[19],"ahau");
while(cin>>n)
{
if (n==0) break;
cout<<n<<endl;
count=0;
while(count++<n)
{
cin>>day>>dot>>month>>year;
if(year>5000) {cout<<"out of limit";break;}
if(day>19) {cout<<"out of limit";break;}
if(strcmp(month,"uayet")==0) { if(day>4) {cout<<"out of limit";break;}}
for(i=0;i<=18;i++)
{
if(strcmp(month,haab)==0)
{
total=(unsigned long) day+(unsigned long)i*20+365*(unsigned long)year;
break;
}
}
if(total>259) tyear=(total/260);
else tyear=0;
total=total%260;
tmonth=total%13+1; //if(tmonth==0) tmonth=13;
dayname=total%20; //if(dayname==0) dayname=20;
cout<<tmonth<<" "<<tzolkin[dayname]<<" "<<tyear<<endl;
}
}
return 0;
}