Submission #897422

# Submission time Handle Problem Language Result Execution time Memory
897422 2024-01-03T05:05:10 Z Faisal_Saqib Wombats (IOI13_wombats) C++17
Compilation error
0 ms 0 KB
#pragma once 
#include <iostream>
#include <set>
using namespace std;
int h[5000][200];
int v[5000][200];
long long dist[5000][200];
int n,m;
bool Valid(int i,int j){
	return (0<=i and i<n and 0<=j and j<m);
}
void init(int r, int c, int H[5000][200], int V[5000][200])
{
	n=r;
	m=c;
	for(int i=0;i<r;i++)
	{
		for(int j=0;j<(c-1);j++)
		{
			h[i][j]=H[i][j];
		}
	}
	for(int i=0;i<(r-1);i++)
	{
		for(int j=0;j<c;j++)
		{
			v[i][j]=V[i][j];
		}
	}
}
void changeH(int p, int q, int w)
{
	h[p][q]=w;
}
void changeV(int p, int q, int w)
{
	v[p][q]=w;
}
int escape(int V1, int V2)
{
	set<pair<long long,pair<int,int>>> sp;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			dist[i][j]=1e18;
		}
	}
	dist[0][V1]=0;
	sp.insert({0,{0,V1}});
	// cout<<"ST "<<0<<' '<<V1<<endl;
	while(sp.size())
	{
		auto f=*begin(sp);
		// cout<<"Hola "<<f.second.first<<' '<<f.second.second<<' '<<f.first<<endl;;
		if(f.second.first==(n-1) and f.second.second==V2)
			return f.first;
		sp.erase(begin(sp));
		if(Valid(f.second.first+1,f.second.second) and dist[f.second.first+1][f.second.second]>(f.first+v[f.second.first][f.second.second]))
		{
			sp.erase({dist[f.second.first+1][f.second.second],{f.second.first+1,f.second.second}});
			dist[f.second.first+1][f.second.second]=(f.first+v[f.second.first][f.second.second]);
			sp.insert({dist[f.second.first+1][f.second.second],{f.second.first+1,f.second.second}});
		}
		if(Valid(f.second.first,f.second.second+1) and dist[f.second.first][f.second.second+1]>(f.first+h[f.second.first][f.second.second]))
		{
			sp.erase({dist[f.second.first][f.second.second+1],{f.second.first,f.second.second+1}});
			dist[f.second.first][f.second.second+1]=(f.first+h[f.second.first][f.second.second]);
			sp.insert({dist[f.second.first][f.second.second+1],{f.second.first,f.second.second+1}});
		}

		// if(Valid(f.second.first-1,f.second.second) and dist[f.second.first-1][f.second.second]>(f.first+v[f.second.first-1][f.second.second]))
		// {
		// 	sp.erase({dist[f.second.first-1][f.second.second],{f.second.first-1,f.second.second}});
		// 	dist[f.second.first-1][f.second.second]=(f.first+v[f.second.first-1][f.second.second]);
		// 	sp.insert({dist[f.second.first-1][f.second.second],{f.second.first-1,f.second.second}});
		// }
		if(Valid(f.second.first,f.second.second-1) and dist[f.second.first][f.second.second-1]>(f.first+h[f.second.first][f.second.second-1]))
		{
			// cout<<"For now "<<v[f.second.first][f.second.second-1]<<endl;
			sp.erase({dist[f.second.first][f.second.second-1],{f.second.first,f.second.second-1}});
			dist[f.second.first][f.second.second-1]=(f.first+h[f.second.first][f.second.second-1]);
			sp.insert({dist[f.second.first][f.second.second-1],{f.second.first,f.second.second-1}});
		}
	}
	return 0;
}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
wombats.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
/usr/bin/ld: /tmp/ccZDRmim.o: in function `main':
grader.c:(.text.startup+0x129): undefined reference to `init'
/usr/bin/ld: grader.c:(.text.startup+0x194): undefined reference to `escape'
/usr/bin/ld: grader.c:(.text.startup+0x203): undefined reference to `changeH'
/usr/bin/ld: grader.c:(.text.startup+0x26d): undefined reference to `changeV'
collect2: error: ld returned 1 exit status