Page 2 of 5
Posted: Mon Jun 23, 2003 1:09 pm
by Pupirev Sergei
Both codes got AC.
How did you got PE?
surprising
Posted: Mon Jun 23, 2003 8:23 pm
by reza ali
Mr. Pupirev,
This is the mystry. For your kind information I use Turbo C++ 3.0 compiler for coding and use online submatic 0.6 for submission.The first code , I got 2 times AC(PE) but your correction that is 2nd one I got only AC.Which one you use for coding and submission?
Try to explain it please.
Thanks
Posted: Tue Jun 24, 2003 9:17 pm
by reza ali
MR. Pupirev
At last I got accepeted of my code copying from board.I don't know why such things happend. Anyway, thanks to you.
300 - Maya Calendar
Posted: Wed Feb 25, 2004 10:18 am
by Ferdous
I am quiet frustrated !!!!!!! I got Run Time Error but can't find out what the flaw is. I would be very much glad if anyone comes forward to help me in finding that flaw.
my code has been deleted as I got AC
Posted: Thu Mar 04, 2004 1:02 pm
by helmet
I am not quite sure what your runtime error is...but I am quite distressed by the way you havent used the modulus operator(%) instead of subtracting everytime...
ie
instead of w=x/y
z=x-w*y
do z=x%y
Posted: Thu Mar 04, 2004 8:32 pm
by Raiyan Kamal
How about leading zero(s) and space(s) before the haab day? There might be cases like these :
0000000000001. pop 0
001. pop 00001
____1. pop 1
('_' means space )
Hope this will help you.
Posted: Fri Mar 05, 2004 5:41 am
by sidky
The Haab Months can be given in upper case. So, ignore the case while comparing.
Posted: Fri Mar 05, 2004 10:16 am
by Raiyan Kamal
Dear Sidky, I dont think there are upper case letters in the input. I did not handle that and my code was AC. By the way, I got same time as you in this.
For Ferdous,
look at your haab months! You have a month named "cumlu" but it should be "cumhu" !!
This mistake is enough to give you a RTE.
Posted: Fri Mar 05, 2004 2:39 pm
by Ferdous
I made changes in my code as Raiyan and sidky told. But it has ushered in new horizon of frustration !!!!!! This time it is awarded WA. This kind of situation really makes me averse to problem solving. I just can't understand what to do....... can't find any fault. Please extend to me your helping hands and for that I would be evergrateful.
Posted: Fri Mar 05, 2004 5:04 pm
by Raiyan Kamal
Firstly, I recommend that you take the haab day input as long or unsigned long instead of string.
Secondly, try this : -
Code: Select all
total = h_year*365 + i*20 + h_day ; // dont add the 1 here
t_year = total/260;
current = total%260;
t_month = current%20;
if(!t_month) t_month = 20;
t_day = current%13 + 1; // add the 1 here
//if(!t_day) t_day = 13;
Posted: Sun Mar 07, 2004 8:08 am
by Ferdous
Raiyan, I made the following change but this time also it's awarded WA.
scanf("%lu %c %s %lu", &h_day, &a, h_month, &h_year); // a for '.'
instead of
scanf("%s %s %lu", a, h_month, &h_year); // a for haab day with '.'
I tried according to your second way of fixing mistake. But it gives wrong answer for 0. pop 0. So I changed my code according to your first way but.....WA. By the way, can anybody tell me whether my algorithm for solving this problem is right?
Posted: Sun Mar 07, 2004 9:01 am
by Raiyan Kamal
You can take the input like this :
hd=haab day;hm=haab month;hy=haab year;
I don't know wheather it'll make any differecnce or not.
This is what I did in the calculation part :
Code: Select all
d=hy*365 + i*20 + hd;
ty=d/260;
d=(d-ty*260);
td=d%13 + 1;
strcpy(tm,tzolkin[d%20]);
d=total days. total in your code.
ty=tzolkin year
td=tzolkin day( the period )
tm=tzolking name of the day.
The t_month can be 0, no need to make it 20 if it is 0. just print the 0th element from the array. Do same in all other cases, print the nth element , not the (n-1)th.
If you still get WA, then give me your email address and before doing that, make sure that there is no spelling mistakes in your tzolkin months and also chek their ordering.
Posted: Sun Mar 07, 2004 9:22 am
by Ferdous
finally I have received AC

. Thank you very very much for your great help.
By the way, I can't understand what difference it makes when I change that portion. Would you please explain it?
300 -> Invalid memory reference
Posted: Fri Mar 12, 2004 8:58 pm
by zaj_tam
I get runtime error:
Your program has died with signal 11 (SIGSEGV). Meaning:
Invalid memory reference
Before crash, it ran during 0.000 seconds.
I have no idea what this means
The code:
Code: Select all
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
using namespace std;
int get_month (char name [6],char haab_month [19][6]);
int main(int argc, char *argv[])
{
int haab_year = 0;
int tzolkin_year = 0;
int num_entries;
int current_month_haab;
char haab_month [19][6];
strcpy(haab_month[0], "pop");
strcpy(haab_month[1], "no");
strcpy(haab_month[2], "zip");
strcpy(haab_month[3], "zotz");
strcpy(haab_month[4], "tzec");
strcpy(haab_month[5], "xul");
strcpy(haab_month[6], "yoxkin");
strcpy(haab_month[7], "mol");
strcpy(haab_month[8], "chen");
strcpy(haab_month[9], "yax");
strcpy(haab_month[10], "zac");
strcpy(haab_month[11], "ceh");
strcpy(haab_month[12], "mac");
strcpy(haab_month[13], "kankin");
strcpy(haab_month[14], "muan");
strcpy(haab_month[15], "pax");
strcpy(haab_month[16], "koyab");
strcpy(haab_month[17], "cumhu");
strcpy(haab_month[18], "uayet");
char tzolkin_day [20][8];
int tzolkin_period_count = 13;
strcpy(tzolkin_day[0], "imix");
strcpy(tzolkin_day[1], "ik");
strcpy(tzolkin_day[2], "akbal");
strcpy(tzolkin_day[3], "kan");
strcpy(tzolkin_day[4], "chicchan");
strcpy(tzolkin_day[5], "cimi");
strcpy(tzolkin_day[6], "manik");
strcpy(tzolkin_day[7], "lamat");
strcpy(tzolkin_day[8], "muluk");
strcpy(tzolkin_day[9], "ok");
strcpy(tzolkin_day[10], "chuen");
strcpy(tzolkin_day[11], "eb");
strcpy(tzolkin_day[12], "ben");
strcpy(tzolkin_day[13], "ix");
strcpy(tzolkin_day[14], "mem");
strcpy(tzolkin_day[15], "cib");
strcpy(tzolkin_day[16], "caban");
strcpy(tzolkin_day[17], "eznab");
strcpy(tzolkin_day[18], "canac");
strcpy(tzolkin_day[19], "ahau");
int buff_first [20];
char buff_second [20][8];
int buff_third [20];
char a [3], b [6];
int c;
int announce;
int iks = 0;
scanf("%d", &announce);
while ( iks < announce )
{
scanf("%s", a);
scanf("%s", b);
scanf("%d", &c);
int haab_days;
haab_days = get_month (b,haab_month) * 20 + atoi(a) + (365 * c);
int tzolkin_first_conv = (haab_days + 1) % 13;
char tzolkin_char_conv [8];
strcpy(tzolkin_char_conv, tzolkin_day[(((haab_days + 1) % 20)-1)]);
int tzolkin_year_conv = (haab_days - tzolkin_first_conv) / 260;
if ( tzolkin_year_conv >= 1 ) { } else { tzolkin_year_conv = 0; }
buff_first[iks] = tzolkin_first_conv;
strcpy(buff_second[iks], tzolkin_char_conv);
buff_third[iks] = tzolkin_year_conv;
iks++;
}
for ( int pimp; pimp < iks; pimp++ )
{
printf("%d %s %d\n", buff_first[pimp], buff_second[pimp],
buff_third[pimp]);
}
return 0;
}
int get_month (char name [6],char haab_month [19][6])
{
int n = 0;
while ( 0 != strcmp( name, haab_month[n] ) )
{
n++;
}
return n;
}
Posted: Sat Mar 13, 2004 9:37 am
by Raiyan Kamal
You get this RTE if your program attempts to access any location out of bounds. May be some bug in your code causing the program to access beyond the array lmits you've declared or may be something like that. And also chek the spellings and the ordering of months. Spelling mistake can cause RTE in this problem. I know some people who got RTE because of wrong spelling of Haab or Tzolkin months.