Submission #360609

# Submission time Handle Problem Language Result Execution time Memory
360609 2021-01-28T05:13:34 Z juggernaut Sky Walking (IOI19_walk) C++14
10 / 100
4000 ms 102096 KB
#include<bits/stdc++.h>
#include"walk.h"
#ifndef EVAL
#include"grader.cpp"
#endif
using namespace std;
vector<int>e[100000],b[100000];
vector<pair<int,int>>adj[100000];
long long min_distance(vector<int>x,vector<int>h,vector<int>l,vector<int>r,vector<int>y,int s,int g){
	map<int,int>curr;
	priority_queue<pair<long long,pair<int,int>>>q;
	map<pair<int,int>,long long>val;
	set<pair<int,int>>vis;
	for(int i=0;i<r.size();i++){
		e[r[i]].push_back(y[i]);
		b[l[i]].push_back(y[i]);
	}
	for(int i=0;i<x.size();i++){
		for(auto& to:curr){
			if(to.first>h[i])break;
			adj[i].push_back({to.second,to.first});
			adj[to.second].push_back({i,to.first});
			to.second=i;
		}
		for(auto to:e[i])curr.erase(to);
		for(auto to:b[i])curr[to]=i;
	}
	val[{s,0}]=0;
	q.push({0,{s,0}});
	while(!q.empty()){
		auto v=q.top().second;
		q.pop();
		if(vis.count(v))continue;
		vis.insert(v);
		for(auto to:adj[v.first]){
			if(vis.count(to)||(val.count(to)&&val[to]<=val[v]+abs(v.second-to.second)+abs(x[v.first]-x[to.first])))continue;
			val[to]=val[v]+abs(v.second-to.second)+abs(x[v.first]-x[to.first]);
			q.push({-val[to],to});
		}
	}
	long long ans=1e18;
	for(auto v:val)
		if(v.first.first==g)ans=min(ans,v.second+v.first.second);
	if(ans==1e18)ans=-1;
	return ans;
}

Compilation message

walk.cpp: In function 'long long int min_distance(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, int, int)':
walk.cpp:14:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int i=0;i<r.size();i++){
      |              ~^~~~~~~~~
walk.cpp:18:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int i=0;i<x.size();i++){
      |              ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7404 KB Output is correct
2 Correct 5 ms 7404 KB Output is correct
3 Correct 6 ms 7404 KB Output is correct
4 Correct 5 ms 7404 KB Output is correct
5 Correct 8 ms 7404 KB Output is correct
6 Correct 7 ms 7404 KB Output is correct
7 Correct 7 ms 7404 KB Output is correct
8 Correct 7 ms 7404 KB Output is correct
9 Correct 6 ms 7404 KB Output is correct
10 Correct 9 ms 7532 KB Output is correct
11 Correct 5 ms 7404 KB Output is correct
12 Correct 5 ms 7404 KB Output is correct
13 Correct 5 ms 7404 KB Output is correct
14 Correct 5 ms 7404 KB Output is correct
15 Correct 5 ms 7404 KB Output is correct
16 Correct 5 ms 7404 KB Output is correct
17 Correct 10 ms 7532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7404 KB Output is correct
2 Correct 5 ms 7404 KB Output is correct
3 Execution timed out 4048 ms 48676 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 173 ms 18284 KB Output is correct
2 Execution timed out 4065 ms 102096 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 173 ms 18284 KB Output is correct
2 Execution timed out 4065 ms 102096 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7404 KB Output is correct
2 Correct 5 ms 7404 KB Output is correct
3 Correct 6 ms 7404 KB Output is correct
4 Correct 5 ms 7404 KB Output is correct
5 Correct 8 ms 7404 KB Output is correct
6 Correct 7 ms 7404 KB Output is correct
7 Correct 7 ms 7404 KB Output is correct
8 Correct 7 ms 7404 KB Output is correct
9 Correct 6 ms 7404 KB Output is correct
10 Correct 9 ms 7532 KB Output is correct
11 Correct 5 ms 7404 KB Output is correct
12 Correct 5 ms 7404 KB Output is correct
13 Correct 5 ms 7404 KB Output is correct
14 Correct 5 ms 7404 KB Output is correct
15 Correct 5 ms 7404 KB Output is correct
16 Correct 5 ms 7404 KB Output is correct
17 Correct 10 ms 7532 KB Output is correct
18 Correct 5 ms 7404 KB Output is correct
19 Correct 5 ms 7404 KB Output is correct
20 Execution timed out 4048 ms 48676 KB Time limit exceeded
21 Halted 0 ms 0 KB -