Submission #722584

#TimeUsernameProblemLanguageResultExecution timeMemory
722584yeysoRainforest Jumps (APIO21_jumps)C++14
0 / 100
4089 ms10652 KiB
#include "jumps.h" #include <bits/stdc++.h> using namespace std; #include <vector> vector<vector<int>> adj; vector<int> v; void init(int n, vector<int> h) { // adjancency matrix adj.assign(n, vector<int>()); v.assign(n, 0); for(int i = 0; i < n; i ++){ // jumps to the right for(int j = i + 1; j < n; j ++){ if(h[j] > h[i]){ adj[i].push_back(j); break; } } // jumps to the left for(int j = i - 1; j >= 0; j --){ if(h[j] > h[i]){ adj[i].push_back(j); break; } } } } int minimum_jumps(int a, int b, int c, int d) { // DISTANCE THEN NODE queue<pair<int, int>> q; for(int i = a; i <= b; i ++){ q.push({0, i}); } int node = 0; int dist = 0; int res = -1; while(!q.empty()){ node = q.front().second; dist = q.front().first; q.pop(); if(!v[node]){ v[node] = 1; for(int i = 0; i < adj[node].size(); i ++){ q.push({dist+1, adj[node][i]}); } if(c <= node and node <= d){ res = dist; //cout << node << " "; } } } return res; }

Compilation message (stderr)

jumps.cpp: In function 'int minimum_jumps(int, int, int, int)':
jumps.cpp:43:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |             for(int i = 0; i < adj[node].size(); i ++){
      |                            ~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...