답안 #429450

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
429450 2021-06-16T00:04:34 Z Pbezz Sky Walking (IOI19_walk) C++14
10 / 100
4000 ms 608676 KB
#include "walk.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
typedef pair<int,int>pii;

const ll MAXN = 1e5+5;
const ll INF = 1e16+7;
vector<vector<int>>has(MAXN);
//has[i] e lista de alturas em que i e intersetado

map<pii,vector<pair<pii,int>> >adj;
//mapi[{i,j}] e vector de pares adjacente,dist
map<pii,ll>dist;
map<pii,bool>visited;
long long 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) {

	int i,j,prev,n=x.size(),m=l.size();

	for(j=0;j<m;j++){
for(i=l[j];i<=r[j];i++){
	if(h[i]>=y[j]){
	has[i].pb(y[j]);
	}
}
	}

	for(i=0;i<n;i++){
	has[i].pb(0);
	sort(has[i].begin(),has[i].end());
	}

	for(i=0;i<n;i++){
	for(j=1;j<(int)has[i].size();j++){
	adj[{i,has[i][j]}].pb({ {i,has[i][j-1]} ,has[i][j]-has[i][j-1]});
	adj[{i,has[i][j-1]}].pb({ {i,has[i][j]} ,has[i][j]-has[i][j-1]});
	}
}

	for(j=0;j<m;j++){
prev=l[j];
for(i=l[j]+1;i<=r[j];i++){
	if(h[i]<y[j])continue;

	adj[{prev,y[j]}].pb({ {i,y[j]} , x[i]-x[prev]});
	adj[{i,y[j]}].pb({ {prev,y[j]} , x[i]-x[prev]});

prev=i;
}
	}

//dijkstra
priority_queue< pair<ll,pii> >p;
	for(i=0;i<n;i++){
	for(j=0;j<(int)has[i].size();j++){
	dist[{i,has[i][j]}]=INF;
//	visited[{i,has[i][j]}]=false;
	}
}
p.push({0,{s,0}});
dist[{s,0}]=0;
pii cur,a;

while(!p.empty()){
cur=p.top().second;
p.pop();
if(visited[cur])continue;
visited[cur]=true;
for(auto u:adj[cur]){

if(dist[u.first]>dist[cur]+u.second){
dist[u.first]=dist[cur]+u.second;
p.push({-dist[u.first],u.first});

}


}

}



	if(visited[{g,0}]){
	return dist[{g,0}];
	}else{
	return -1;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 3 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 5 ms 2764 KB Output is correct
6 Correct 3 ms 2764 KB Output is correct
7 Correct 3 ms 2764 KB Output is correct
8 Correct 3 ms 2764 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 4 ms 2892 KB Output is correct
11 Correct 3 ms 2636 KB Output is correct
12 Correct 2 ms 2636 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 2 ms 2572 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 4 ms 2892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Execution timed out 4098 ms 203992 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 273 ms 25588 KB Output is correct
2 Execution timed out 4127 ms 608676 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 273 ms 25588 KB Output is correct
2 Execution timed out 4127 ms 608676 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 3 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 5 ms 2764 KB Output is correct
6 Correct 3 ms 2764 KB Output is correct
7 Correct 3 ms 2764 KB Output is correct
8 Correct 3 ms 2764 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 4 ms 2892 KB Output is correct
11 Correct 3 ms 2636 KB Output is correct
12 Correct 2 ms 2636 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 2 ms 2572 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 4 ms 2892 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2636 KB Output is correct
20 Execution timed out 4098 ms 203992 KB Time limit exceeded
21 Halted 0 ms 0 KB -