Submission #786058

# Submission time Handle Problem Language Result Execution time Memory
786058 2023-07-18T01:08:32 Z MODDI Wombats (IOI13_wombats) C++14
Compilation error
0 ms 0 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
map<pair<pii,pii>, int> cost;
int r, c;
void init(int R, int C, int H[5000][200], int V[5000][200]) {
	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];
		}
	}
}

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;
		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)));
		}
		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];
}

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:4:10: error: 'pii' was not declared in this scope
    4 | map<pair<pii,pii>, int> cost;
      |          ^~~
wombats.cpp:4:14: error: 'pii' was not declared in this scope
    4 | map<pair<pii,pii>, int> cost;
      |              ^~~
wombats.cpp:4:17: error: template argument 1 is invalid
    4 | map<pair<pii,pii>, int> cost;
      |                 ^
wombats.cpp:4:17: error: template argument 2 is invalid
wombats.cpp:4:23: error: template argument 1 is invalid
    4 | map<pair<pii,pii>, int> cost;
      |                       ^
wombats.cpp:4:23: error: template argument 3 is invalid
wombats.cpp:4:23: error: template argument 4 is invalid
wombats.cpp: In function 'void init(int, int, int (*)[200], int (*)[200])':
wombats.cpp:10:12: error: 'mp' was not declared in this scope
   10 |    cost[mp(mp(i,j), mp(i,j+1))] = H[i][j];
      |            ^~
wombats.cpp:10:9: error: 'mp' was not declared in this scope
   10 |    cost[mp(mp(i,j), mp(i,j+1))] = H[i][j];
      |         ^~
wombats.cpp:15:12: error: 'mp' was not declared in this scope
   15 |    cost[mp(mp(i,j), mp(i+1, j))] = V[i][j];
      |            ^~
wombats.cpp:15:9: error: 'mp' was not declared in this scope
   15 |    cost[mp(mp(i,j), mp(i+1, j))] = V[i][j];
      |         ^~
wombats.cpp: In function 'void changeH(int, int, int)':
wombats.cpp:21:10: error: 'mp' was not declared in this scope
   21 |  cost[mp(mp(P,Q), mp(P,Q+1))] = W;
      |          ^~
wombats.cpp:21:7: error: 'mp' was not declared in this scope
   21 |  cost[mp(mp(P,Q), mp(P,Q+1))] = W;
      |       ^~
wombats.cpp: In function 'void changeV(int, int, int)':
wombats.cpp:25:10: error: 'mp' was not declared in this scope
   25 |  cost[mp(mp(P,Q), mp(P+1, Q))] = W;
      |          ^~
wombats.cpp:25:7: error: 'mp' was not declared in this scope
   25 |  cost[mp(mp(P,Q), mp(P+1, Q))] = W;
      |       ^~
wombats.cpp: In function 'int escape(int, int)':
wombats.cpp:29:2: error: 'll' was not declared in this scope
   29 |  ll dist[r][c];
      |  ^~
wombats.cpp:32:4: error: 'dist' was not declared in this scope
   32 |    dist[i][j] = 1e15;
      |    ^~~~
wombats.cpp:33:2: error: 'dist' was not declared in this scope
   33 |  dist[0][V1] = 0;
      |  ^~~~
wombats.cpp:34:27: error: 'pii' was not declared in this scope
   34 |  priority_queue<pair<int, pii> > pq;
      |                           ^~~
wombats.cpp:34:30: error: template argument 2 is invalid
   34 |  priority_queue<pair<int, pii> > pq;
      |                              ^
wombats.cpp:34:32: error: template argument 1 is invalid
   34 |  priority_queue<pair<int, pii> > pq;
      |                                ^
wombats.cpp:34:32: error: template argument 2 is invalid
wombats.cpp:34:32: error: template argument 3 is invalid
wombats.cpp:35:5: error: request for member 'push' in 'pq', which is of non-class type 'int'
   35 |  pq.push(mp(0, mp(0, V1)));
      |     ^~~~
wombats.cpp:35:16: error: 'mp' was not declared in this scope
   35 |  pq.push(mp(0, mp(0, V1)));
      |                ^~
wombats.cpp:35:10: error: 'mp' was not declared in this scope
   35 |  pq.push(mp(0, mp(0, V1)));
      |          ^~
wombats.cpp:36:12: error: request for member 'empty' in 'pq', which is of non-class type 'int'
   36 |  while(!pq.empty()){
      |            ^~~~~
wombats.cpp:37:6: error: expected ';' before 'at'
   37 |   pii at = pq.top().second;
      |      ^~~
      |      ;
wombats.cpp:38:6: error: request for member 'pop' in 'pq', which is of non-class type 'int'
   38 |   pq.pop();
      |      ^~~
wombats.cpp:39:11: error: 'at' was not declared in this scope
   39 |   int x = at.first, y = at.second;
      |           ^~
wombats.cpp:40:6: error: 'y' was not declared in this scope
   40 |   if(y - 1 >= 0 && dist[x][y-1] > dist[x][y] + cost[mp(mp(x,y-1), mp(x,y))]){
      |      ^
wombats.cpp:42:7: error: request for member 'push' in 'pq', which is of non-class type 'int'
   42 |    pq.push(mp(-dist[x][y-1], mp(x,y-1)));
      |       ^~~~
wombats.cpp:44:6: error: 'y' was not declared in this scope
   44 |   if(y+1 < c && dist[x][y+1] > dist[x][y] + cost[mp(mp(x,y), mp(x,y+1))]){
      |      ^
wombats.cpp:46:7: error: request for member 'push' in 'pq', which is of non-class type 'int'
   46 |    pq.push(mp(-dist[x][y+1], mp(x,y+1)));
      |       ^~~~
wombats.cpp:48:29: error: 'y' was not declared in this scope
   48 |   if(x + 1 < r && dist[x+1][y] > dist[x][y] + cost[mp(mp(x,y), mp(x+1,y))]){
      |                             ^
wombats.cpp:50:7: error: request for member 'push' in 'pq', which is of non-class type 'int'
   50 |    pq.push(mp(-dist[x+1][y], mp(x+1, y)));
      |       ^~~~