You are not logged in. Please login at www.codechef.com to post your questions!

×

Please help in understanding this error?

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[i] - 'A' + 1);
    }
    for(int i=0;i<s2.length ();i++)
    {
        ans2 = ans2 * (s2[i] - 'A' + 1);
    }
    if(ans1%47 == ans2%47)
        cout<<"GO"<<endl;
    else
        cout<<"STAY"<<endl;
    return 0;
}

asked 22 Feb '18, 22:31

montycs's gravatar image

0★montycs
1057
accept rate: 0%


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

link

answered 23 Feb '18, 22:19

montycs's gravatar image

0★montycs
1057
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×27

question asked: 22 Feb '18, 22:31

question was seen: 262 times

last updated: 23 Feb '18, 22:19