Submission #786060

# Submission time Handle Problem Language Result Execution time Memory
786060 2023-07-18T01:14:34 Z MODDI Wombats (IOI13_wombats) C++14
Compilation error
0 ms 0 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define ll long long
map<pair<pii,pii>, int> cost;
int r, c;
void init(int R, int C, int H[5000][200], int V[5000][200]) {
	r = R;
	c = C;
	for(int i = 0; i < R; i++)
	{
		for(int j = 0; j < C-1; j++){
			cost[mp(mp(i,j), mp(i,j+1))] = H[i][j];
		}
	}
	for(int i = 0; i < R-1; i++){
		for(int j = 0; j < C; j++){
			cost[mp(mp(i,j), mp(i+1, j))] = V[i][j];
//			cout<<"COST: "<<i<<" "<<j<<" to "<<i+1<<" "<<j<<" is "<<V[i][j]<<endl;
		}
	}
}

void changeH(int P, int Q, int W) {
	cost[mp(mp(P,Q), mp(P,Q+1))] = W;
}

void changeV(int P, int Q, int W) {
	cost[mp(mp(P,Q), mp(P+1, Q))] = W;
}

int escape(int V1, int V2) {
	ll dist[r][c];
	for(int i = 0; i < r; i++)
		for(int j = 0; j < c; j++)
			dist[i][j] = 1e15;
	dist[0][V1] = 0;
	priority_queue<pair<int, pii> > pq;
	pq.push(mp(0, mp(0, V1)));
	while(!pq.empty()){
		pii at = pq.top().second;
		pq.pop();
		int x = at.first, y = at.second;
//		cout<<x<<" "<<y<<" "<<dist[x][y]<<endl;
		if(y - 1 >= 0 && dist[x][y-1] > dist[x][y] + cost[mp(mp(x,y-1), mp(x,y))]){
			dist[x][y-1] = dist[x][y] + cost[mp(mp(x,y-1), mp(x,y))];
			pq.push(mp(-dist[x][y-1], mp(x,y-1)));
		}
		if(y+1 < c && dist[x][y+1] > dist[x][y] + cost[mp(mp(x,y), mp(x,y+1))]){
			dist[x][y+1] = dist[x][y] + cost[mp(mp(x,y), mp(x,y+1))];
			pq.push(mp(-dist[x][y+1], mp(x,y+1)));
		}
//		cout<<dist[x+1][y]<<" "<<dist[x][y] + cost[mp(mp(x,y), mp(x+1,y))]<<endl;
		if(x + 1 < r && dist[x+1][y] > dist[x][y] + cost[mp(mp(x,y), mp(x+1,y))]){
			dist[x+1][y] = dist[x][y] + cost[mp(mp(x,y), mp(x+1, y))];
			pq.push(mp(-dist[x+1][y], mp(x+1, y)));
		}
	}
	return dist[r-1][V2];
}
	int H[5000][200], V[5000][200];
int main(){
	int r, c;

	cin>>r>>c;
	memset(H, 0, sizeof H);
	for(int i = 0; i < r-1; i++){
		cin>>V[i][0];
	}
	init(r, c, H, V);
	cout<<escape(0, 0)<<endl;
}

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;
      |      ^~~
/usr/bin/ld: /tmp/ccV3yDoc.o: in function `main':
wombats.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc3G7Mja.o:grader.c:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status