Please help in understanding this error?

usaco

#1

I am solving this problem from USACO but on submitting the answer, I get the following error:

 Run 1: Execution error: Your program had this runtime error:
            Illegal file open (test.out). The program ran for 0.000 CPU
            seconds before the error. It used 4300 KB of memory. 
    
            ------ Data for Run 1 [length=14 bytes] ------
            COMETQ 
            HVNGAT 
            ----------------------------

Here is my solution:

   /*
    ID: test1234@
    TASK: ride
    LANG: C++
    */



#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ofstream fout ("test.out");
    ifstream fin ("test.in");
    string s1;
    string s2;
    cin>>s1;
    cin>>s2;
    int ans1,ans2;
    ans1 = ans2 = 1;
    for(int i=0;i<s1.length ();i++)
    {
        ans1 = ans1 * (s1* - 'A' + 1);
    }
    for(int i=0;i<s2.length ();i++)
    {
        ans2 = ans2 * (s2* - 'A' + 1);
    }
    if(ans1%47 == ans2%47)
        cout<<"GO"<<endl;
    else
        cout<<"STAY"<<endl;
    return 0;
}

#2

Ok the problem is solved, had to replace test.in and test.out with ride.in and ride.out