Submission #675541

#TimeUsernameProblemLanguageResultExecution timeMemory
675541QwertyPiOBELISK (NOI14_obelisk)C++14
5 / 25
22 ms1264 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...