Submission #974721

# Submission time Handle Problem Language Result Execution time Memory
974721 2024-05-03T17:04:13 Z NemanjaSo2005 Sky Walking (IOI19_walk) C++17
15 / 100
140 ms 17656 KB
#include "walk.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+5;
int N,M;
map<int,ll> mapa;
vector<int> poc[maxn],kraj[maxn];
ll getdist(int y,int h){
   auto it=mapa.upper_bound(y-1);
   if(it!=mapa.begin())
      it--;
   if(it!=mapa.begin())
      it--;
   if(it!=mapa.begin())
      it--;
   if(it!=mapa.begin())
      it--;
   ll ans=9e18;
   int br=10;
   for(it;it!=mapa.end();it++){
      br--;
      if(br==0)
         break;
      if((it->first)>h)
         break;
      ans=min(ans,(it->second)+abs(y-(it->first)));
   }
   if(ans==9e18)
      return -1;
   return ans;
}
ll min_distance(std::vector<int> x, std::vector<int> h, std::vector<int> l, std::vector<int> r, std::vector<int> y, int s, int g) {
   N=x.size();
	M=l.size();
	for(int i=0;i<M;i++){
      poc[l[i]].push_back(y[i]);
      kraj[r[i]].push_back(y[i]);
	}
	for(int x:poc[0])
      mapa[x]=x;
   for(int i=1;i<N-1;i++){
      if(mapa.size()==0)
         return -1;
      vector<pair<int,ll>> V;
      for(int y:poc[i]){
         ll d=getdist(y,h[i]);
         if(d==-1)
            break;
         V.push_back({y,d});
      }
      for(int x:kraj[i])
         mapa.erase(x);
      for(auto x:V)
         mapa[x.first]=x.second;
   }
   if(mapa.size()==0)
      return -1;
   ll res=9e18;
   for(auto it=mapa.begin();it!=mapa.end();it++)
      res=min(res,(it->first)+(it->second));
	return res+x.back()-x[0];
}

Compilation message

walk.cpp: In function 'long long int getdist(int, int)':
walk.cpp:21:8: warning: statement has no effect [-Wunused-value]
   21 |    for(it;it!=mapa.end();it++){
      |        ^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 7256 KB Output is correct
2 Correct 74 ms 8796 KB Output is correct
3 Correct 84 ms 9304 KB Output is correct
4 Correct 104 ms 13140 KB Output is correct
5 Correct 132 ms 17656 KB Output is correct
6 Correct 124 ms 15408 KB Output is correct
7 Correct 52 ms 10588 KB Output is correct
8 Correct 74 ms 15352 KB Output is correct
9 Correct 126 ms 17076 KB Output is correct
10 Correct 68 ms 16140 KB Output is correct
11 Correct 9 ms 5880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 7256 KB Output is correct
2 Correct 74 ms 8796 KB Output is correct
3 Correct 84 ms 9304 KB Output is correct
4 Correct 104 ms 13140 KB Output is correct
5 Correct 132 ms 17656 KB Output is correct
6 Correct 124 ms 15408 KB Output is correct
7 Correct 52 ms 10588 KB Output is correct
8 Correct 74 ms 15352 KB Output is correct
9 Correct 126 ms 17076 KB Output is correct
10 Correct 68 ms 16140 KB Output is correct
11 Correct 9 ms 5880 KB Output is correct
12 Correct 80 ms 9300 KB Output is correct
13 Correct 56 ms 12824 KB Output is correct
14 Correct 132 ms 17592 KB Output is correct
15 Correct 81 ms 13244 KB Output is correct
16 Correct 84 ms 13136 KB Output is correct
17 Correct 85 ms 13256 KB Output is correct
18 Correct 82 ms 13212 KB Output is correct
19 Correct 85 ms 13148 KB Output is correct
20 Correct 58 ms 10580 KB Output is correct
21 Correct 22 ms 6736 KB Output is correct
22 Correct 68 ms 11228 KB Output is correct
23 Correct 50 ms 11356 KB Output is correct
24 Correct 48 ms 11604 KB Output is correct
25 Correct 47 ms 11348 KB Output is correct
26 Correct 49 ms 12372 KB Output is correct
27 Correct 130 ms 17060 KB Output is correct
28 Correct 64 ms 12880 KB Output is correct
29 Correct 127 ms 15444 KB Output is correct
30 Correct 52 ms 10580 KB Output is correct
31 Correct 140 ms 16928 KB Output is correct
32 Correct 62 ms 14540 KB Output is correct
33 Incorrect 81 ms 15624 KB Output isn't correct
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4956 KB Output isn't correct
2 Halted 0 ms 0 KB -