hello,
i recently joined the USACO's training gateway http://ace.delos.com/usacogate
I made the first problem(http://ace.delos.com/usacoprob2?a=n4y3olVXOJ9&S=ride) and it ran successfully in my dev-cpp compiler. but the online grader threw some runtime error. it was like
Compiling...
Compile: OK
Executing...
> Run 1: Execution error: Your program (`ride') exited with signal
#6 (abort()). The program ran for 0.000 CPU seconds before the
signal. It used 2928 KB of memory.
------ Data for Run 1 ------
COMETQ
HVNGAT
----------------------------
Your program printed data to stderr. Here is the data:
-------------------
terminate_called_after_throwing_an_instance_of_'std::ios_base::failure'
__what():__basic_ios::clear
-------------------
Test 1: SIGNAL 6 (0.000 secs, 2928 KB)
debugging using cerr, i came to a conclusion that there is something with the "fin >>"
statement that is causing problem. my code is
/*
ID: nimeshg1
PROG: ride
LANG: C++
*/
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
ofstream fout;
fout.open("ride.out");
ifstream fin ("ride.in");
char comets[6], groupers[6];
int cno=1,gno=1;
fin >> comets;
fin >> groupers;
for(int i=0;i<6;i++)
{
cno *= ((int)comets[i] - 64);
if(comets[i]=='\0')
i=6;
}
for(int i=0;i<6;i++)
{
gno *= ((int)groupers[i] - 64);
if(comets[i]=='\0')
i=6;
}
if(cno%47 == gno%47)
fout<<"GO"<<endl;
else
fout<<"STAY"<<endl;
return 0;
}
Any suggestions?