Submission #1048000

#TimeUsernameProblemLanguageResultExecution timeMemory
1048000Maite_MoraleRainforest Jumps (APIO21_jumps)C++17
21 / 100
164 ms31832 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define vll vector<ll> #define MAX 2005 #define oo 1e18 #define pll pair<ll,ll> #define F first #define S second const ll bts=20; pll p[MAX]; vll v[MAX]; ll N,pass[MAX][MAX]; void bfs(ll x){ queue<ll> q; q.push(x);pass[x][x]=0; while(!q.empty()){ ll u=q.front();q.pop(); for(auto w : v[u]){ if(pass[x][w]!=-1)continue; pass[x][w]=pass[x][u]+1; q.push(w); } } } void init(int n, std::vector<int> h) { h.push_back(oo); stack<ll> s;s.push(n); for(int i=0;i<n;i++){ while(h[i]>h[s.top()]){ p[s.top()].F=i; if(s.top()!=n)v[s.top()].push_back(i); s.pop(); } p[i].S=s.top(); if(s.top()!=n) v[i].push_back(s.top()); s.push(i); } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ pass[i][j]=-1; } bfs(i); } } int minimum_jumps(int A, int B, int C, int D) { ll r=oo; for(int i=A;i<=B;i++){ for(int j=C;j<=D;j++){ if(pass[i][j]!=-1){ r=min(r,pass[i][j]); } } } if(r==oo)return -1; return r; }

Compilation message (stderr)

jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:6:12: warning: overflow in conversion from 'double' to 'std::vector<int>::value_type' {aka 'int'} changes value from '1.0e+18' to '2147483647' [-Woverflow]
    6 | #define oo 1e18
      |            ^~~~
jumps.cpp:28:17: note: in expansion of macro 'oo'
   28 |     h.push_back(oo);
      |                 ^~
#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...