UVA Runtime Error Help

Working on UVA 11947: Cancer and Scorpio. I keep getting a runtime error and I dont know why.

Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=24&problem=3098&mosmsg=Submission+received+with+ID+13655102

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <sstream>


using namespace std;

long toInt(string a)
{
	istringstream buf(a);
	long ret;
	buf>>ret;
	return ret;	
}

bool isLeap(int year)
{
	if(year%4==0 && year%100!=0)
	{
		return true;
	}
	else if(year%400==0)
	{
		return true;
	}
	else 
	{
		return false; 
	}
}

int month_length[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

pair <int,int> signs[13];



string sign_name[]={"aquarius","pisces", "aries", "taurus","gemini", "cancer", "leo","virgo", "libra",
					"scorpio","sagittarius","capricorn"};

int findsign(const int m, const int d)
{
	int ret;
	ret=m-1;
	if(d<=signs[ret].second){ret--;}
	return ret; 
	
	
}

int main()
{
	
	signs[0]= make_pair (1,21);
	signs[1] = make_pair (2,20);
	signs[2] = make_pair (3,21); 
	signs[3] = make_pair (4,21);
	signs[4] = make_pair (5,22); 
	signs[5] = make_pair (6,22);
	signs[6] = make_pair (7,23);
	signs[7] = make_pair (8,22);
	signs[8] = make_pair (9,24);
	signs[9] = make_pair (10,24);
	signs[10] = make_pair (11,23);
	signs[11] = make_pair (12,23);
	signs[12] = make_pair (1,20);
	

	int runs,temp,m,d,y,move;
	string input;

	cin >> runs; 

	for(int i=0; i<runs; ++i)
	{
		cin >> input;
		//cout << input << endl;

		string month=input.substr(0,2);
		string day= input.substr(2,2);
		string year= input.substr(4);
		//cout << month << " "<< day << " "<< year << endl;

		 m=toInt(month);
		 d=toInt(day);
		 y=toInt(year);

		 //cout << m << " "<< d <<" " << y << endl;
		 move=0;

		while(move<280)
		{
			if(isLeap(y))
			{
				month_length[2]++;
			}

			if(280-move>month_length[m])
			{

				move+= month_length[m]-d; 
				d=0; 
				if(m==12) {m=1; y++;}
				else {m++;}
			}
			else
			{
				d+=280-move;
				cout << i+1 << " ";

				
				 temp= findsign(m,d);
			
				if(m<10){cout << "0" << m << "/";}
				else{cout << m << "/";}

				if(d<10){cout << "0" << d << "/";}
				else{cout << d << "/";}

				cout << y << " ";

				cout << sign_name[temp]; 
				cout << endl;
				

				break;
			}


			if(month_length[2]!=28){month_length[2]--;}
			
		}

	}
	return 0; 
}
What does the error say?
UVA simply says runtime error. But in my MacBook Pro it compiles and runs normally
If it runs fine on one computer but not another, it could either be a compatibility issue with the functions you're using, or a lack of libraries on one computer but not the other.
Would you know how to fix that?
No, sorry. I don't have a mac.
Or undefined behaviour, or lazy testing.

Checkout if `findsign()' is returning an out of bounds index (-1 or 12)
Topic archived. No new replies allowed.