Submission #675541

# Submission time Handle Problem Language Result Execution time Memory
675541 2022-12-27T12:16:50 Z QwertyPi OBELISK (NOI14_obelisk) C++14
5 / 25
22 ms 1264 KB
#include <bits/stdc++.h>

using namespace std;

struct point{
	int x, y;
};

int dis(point a, point b){
	return abs(a.x - b.x) + abs(a.y - b.y);
}

int dp[501][101];
vector<point> layers[501];
int main(){
	int K, m; cin >> K >> m;
	int s_x, s_y, e_x, e_y;
	cin >> s_x >> s_y >> e_x >> e_y;
	point s {s_x, s_y}, e {e_x, e_y};
	layers[0].push_back(s);
	for(int i = 1; i < K; i++){
		int l; cin >> l;
		for(int j = 0; j < l; j++){
			int x, y; cin >> x >> y;
			layers[i].push_back({x, y});
		}
	}
	layers[K].push_back(e);
	
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0] = 0;
	for(int i = 0; i < K; i++){
		for(int j = 0; j < layers[i].size(); j++){
			for(int k = 0; k < layers[i + 1].size(); k++){
				dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + dis(layers[i][j], layers[i + 1][k]));
			}
		}
	}
	cout << dp[K][0] << endl;
}

Compilation message

obelisk.cpp: In function 'int main()':
obelisk.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for(int j = 0; j < layers[i].size(); j++){
      |                  ~~^~~~~~~~~~~~~~~~~~
obelisk.cpp:34:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |    for(int k = 0; k < layers[i + 1].size(); k++){
      |                   ~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 1264 KB Output isn't correct
2 Halted 0 ms 0 KB -