Example #1
0
int main() {
	int i,j;

#include "83.3.txt"



	for(int i=0;i<size;++i) {
		for(j=0;j<size;++j) {
			array[i][j].set(i,j);
		}
	}

	array[0][0].minsum=numbers[0][0];
	Q.insert(array[0][0]);

	burn();
}
Example #2
0
void burn() {
	leaf top;

	// while(true) {

		top=Q.min();

		std::cout<<"____"<<top<<"____\n";

		if(top.i==size-1 && top.j==size-1){
			std::cout<<top.minsum<<std::endl;
			return;
		}

		array[top.i][top.j].visited=true;
		top.findneighbours();

		int z;

		Q.removemin();
		// std::cout<<"\nQueue...\n";
		// Q.print();
		// std::cout<<"############\n\n";
		for(z=0;z<top.neighbours.size();++z) {
			top.neighbours[z].add(top.minsum);
			// std::cout<<"    "<<top.neighbours[z]<<'\n';
			Q.insert(top.neighbours[z]);
		}


	// int i, j;

	// for(i=0;i<5;++i){
	// 	for(j=0;j<5;++j){
	// 		std::cout<<array[i][j].visited<<" ";
	// 	}
	// 	std::cout<<"\n";
	// }

	// std::cin.get();
	burn();
	// }
}
 V& operator [](K key) {
   typename avl_tree<node>::node *n =
     tree.find(node(key, V(0)));
   if (!n) n = tree.insert(node(key, V(0)));
   return n->item.value; } };