Acyclic graph

Hi guys.I need your help.I have a homework about acyclic graph.I will read some information from input file,after that I will create a output file.I have a rectangular grid where each grid location has an associated value.You are asked to nd a path with the maximum score.A path can start from any location, and end
in any other location, and cannot visit a grid location more than once.how can I start to visit on path??

my input file
1
2
3
4
5
6
7
8
9
10

7 5   //first line rows and colums
-1 -1  // second line magic location 
1 2 3 4 3 // this and another lines grid values.
1 1 1 2 2
2 1 4 2 1
3 2 2 2 4
3 3 3 1 1
3 4 4 2 4
3 1 3 4 3


my program is
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

#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <string>
#include<vector>
using namespace std;

int rows,cols;
int main()
{
	int first,second;
	ifstream myfile("input.txt");
	if (myfile.is_open())
	{
		myfile >>rows;
		myfile >>cols;
	}
	
	vector< vector<int> > grid(rows, vector<int>(cols));
	if (myfile.is_open())
	{
		myfile >>first;
		myfile >>second;
	}
	if (myfile.is_open())
	for(int i=0; i<rows; i++)
	{
		for (int j=0; j<cols;j++)
		{
			myfile >>grid[i][j];
		}
	}


	
	ofstream output_file ("hada.txt");
	for(int i=0; i<rows; i++)
	{
		for (int j=0; j<cols;j++)
		{
			output_file<<grid[i][j];
		}
	}
	output_file.close();

	
 
return 0;
}

I am reading grid values from file and writing them to file right now.But,right now ,what should I do firstly??

my output file should be as follows,,
1
2
3
4
5
6
7
8
9
10
11
12
13
8   //The first line is the number of steps.
800 //Second line is the maximum score found
2 2 //Remaining lines are the grid locations traveled
1 2
1 3
1 4
1 5
2 5
3 5
3 4


Start from any node. When process is finished start from any other node which was not visited, etc.
Topic archived. No new replies allowed.