Submission #411406

# Submission time Handle Problem Language Result Execution time Memory
411406 2021-05-25T08:28:32 Z 장태환(#7572) Sky Walking (IOI19_walk) C++17
24 / 100
750 ms 428020 KB
#include "walk.h"
#include <algorithm>
#include <set>
#include <queue>
#include <string.h>
using namespace std;
#define int long long
vector<pair<int, int>>re;
vector<pair<int, int>>link[2000100];
pair<int, int>bef[200100];
multiset<pair<int,int>>se;
long long dist[2000100];
int vis[2000100];
long long min_distance(std::vector<signed> x, std::vector<signed> h, std::vector<signed> l, std::vector<signed> r, std::vector<signed> y, signed s, signed g)
{
	int N = x.size();
	int M = l.size();
	int i;
	int vc = 0;
	for (i = 0; i < N; i++)
	{
		re.push_back({ x[i],i });
	}
	for (i = 0; i < M; i++)
	{
		re.push_back({ x[l[i]],-i-1 });
		re.push_back({ x[r[i]] + 1,-i-M-1 });
	}
	sort(re.begin(), re.end());

	int curv = N;
	for (i = 0; i < re.size(); i++)
	{
		if (re[i].second >= 0)
		{
			int befh = 0;
			int befv = re[i].second;
			for (auto j = se.begin(); j != se.end(); j++)
			{
				if ((*j).first > h[re[i].second])
					break;
				int he = (*j).first;
				link[befv].push_back({ curv,he - befh });
				link[curv].push_back({ befv,he - befh });
				int ve = (*j).second;
				if (bef[ve].second)
				{
					link[bef[ve].second].push_back({ curv,re[i].first - bef[ve].first });
					link[curv].push_back({ bef[ve].second,re[i].first - bef[ve].first });
				}
				bef[ve] = { re[i].first,curv };
				befh = he;
				befv = curv;
				curv++;
			}
		}
		else if (re[i].second >=-M)
		{
			int te = -re[i].second - 1;
			se.insert({ y[te],te });
		}
		else
		{
			int te = -re[i].second - 1-M;
			se.erase({ y[te],te });
		}
	}
	memset(dist, 1, sizeof(dist));
	priority_queue<pair<int, int>>pq;
	pq.push({ 0,s });
	while (pq.size())
	{
		auto a = pq.top();
		pq.pop();
		if (vis[a.second])
			continue;
		vis[a.second] = 1;
		for (i = 0; i < link[a.second].size(); i++)
		{
			if (dist[link[a.second][i].first] > -a.first + link[a.second][i].second)
			{
				dist[link[a.second][i].first] = -a.first + link[a.second][i].second;
				pq.push({ -dist[link[a.second][i].first],link[a.second][i].first });
			}
		}
	}
	return (dist[g]>(1LL<<50))?-1:dist[g];
}

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:32:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for (i = 0; i < re.size(); i++)
      |              ~~^~~~~~~~~~~
walk.cpp:78:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |   for (i = 0; i < link[a.second].size(); i++)
      |               ~~^~~~~~~~~~~~~~~~~~~~~~~
walk.cpp:19:6: warning: unused variable 'vc' [-Wunused-variable]
   19 |  int vc = 0;
      |      ^~
# Verdict Execution time Memory Grader output
1 Correct 32 ms 62788 KB Output is correct
2 Correct 32 ms 62852 KB Output is correct
3 Correct 32 ms 62872 KB Output is correct
4 Correct 32 ms 62848 KB Output is correct
5 Correct 32 ms 62904 KB Output is correct
6 Correct 36 ms 62916 KB Output is correct
7 Correct 32 ms 62940 KB Output is correct
8 Correct 33 ms 62912 KB Output is correct
9 Correct 31 ms 62868 KB Output is correct
10 Correct 32 ms 62924 KB Output is correct
11 Correct 34 ms 62804 KB Output is correct
12 Correct 32 ms 62900 KB Output is correct
13 Correct 33 ms 62900 KB Output is correct
14 Correct 32 ms 62912 KB Output is correct
15 Correct 35 ms 62896 KB Output is correct
16 Correct 32 ms 62844 KB Output is correct
17 Correct 32 ms 62880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 62924 KB Output is correct
2 Correct 33 ms 62888 KB Output is correct
3 Correct 446 ms 130848 KB Output is correct
4 Correct 442 ms 135964 KB Output is correct
5 Correct 292 ms 123960 KB Output is correct
6 Correct 257 ms 117800 KB Output is correct
7 Correct 271 ms 124164 KB Output is correct
8 Correct 561 ms 150236 KB Output is correct
9 Correct 313 ms 125472 KB Output is correct
10 Correct 586 ms 166388 KB Output is correct
11 Correct 280 ms 104948 KB Output is correct
12 Correct 198 ms 94996 KB Output is correct
13 Correct 503 ms 154484 KB Output is correct
14 Correct 199 ms 91196 KB Output is correct
15 Correct 246 ms 95108 KB Output is correct
16 Correct 215 ms 94868 KB Output is correct
17 Correct 200 ms 93476 KB Output is correct
18 Correct 271 ms 99080 KB Output is correct
19 Correct 42 ms 64448 KB Output is correct
20 Correct 115 ms 78408 KB Output is correct
21 Correct 182 ms 92860 KB Output is correct
22 Correct 198 ms 94240 KB Output is correct
23 Correct 307 ms 106116 KB Output is correct
24 Correct 203 ms 94392 KB Output is correct
25 Correct 204 ms 93780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 99 ms 76124 KB Output is correct
2 Runtime error 750 ms 428020 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 99 ms 76124 KB Output is correct
2 Runtime error 750 ms 428020 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 62788 KB Output is correct
2 Correct 32 ms 62852 KB Output is correct
3 Correct 32 ms 62872 KB Output is correct
4 Correct 32 ms 62848 KB Output is correct
5 Correct 32 ms 62904 KB Output is correct
6 Correct 36 ms 62916 KB Output is correct
7 Correct 32 ms 62940 KB Output is correct
8 Correct 33 ms 62912 KB Output is correct
9 Correct 31 ms 62868 KB Output is correct
10 Correct 32 ms 62924 KB Output is correct
11 Correct 34 ms 62804 KB Output is correct
12 Correct 32 ms 62900 KB Output is correct
13 Correct 33 ms 62900 KB Output is correct
14 Correct 32 ms 62912 KB Output is correct
15 Correct 35 ms 62896 KB Output is correct
16 Correct 32 ms 62844 KB Output is correct
17 Correct 32 ms 62880 KB Output is correct
18 Correct 33 ms 62924 KB Output is correct
19 Correct 33 ms 62888 KB Output is correct
20 Correct 446 ms 130848 KB Output is correct
21 Correct 442 ms 135964 KB Output is correct
22 Correct 292 ms 123960 KB Output is correct
23 Correct 257 ms 117800 KB Output is correct
24 Correct 271 ms 124164 KB Output is correct
25 Correct 561 ms 150236 KB Output is correct
26 Correct 313 ms 125472 KB Output is correct
27 Correct 586 ms 166388 KB Output is correct
28 Correct 280 ms 104948 KB Output is correct
29 Correct 198 ms 94996 KB Output is correct
30 Correct 503 ms 154484 KB Output is correct
31 Correct 199 ms 91196 KB Output is correct
32 Correct 246 ms 95108 KB Output is correct
33 Correct 215 ms 94868 KB Output is correct
34 Correct 200 ms 93476 KB Output is correct
35 Correct 271 ms 99080 KB Output is correct
36 Correct 42 ms 64448 KB Output is correct
37 Correct 115 ms 78408 KB Output is correct
38 Correct 182 ms 92860 KB Output is correct
39 Correct 198 ms 94240 KB Output is correct
40 Correct 307 ms 106116 KB Output is correct
41 Correct 203 ms 94392 KB Output is correct
42 Correct 204 ms 93780 KB Output is correct
43 Correct 99 ms 76124 KB Output is correct
44 Runtime error 750 ms 428020 KB Execution killed with signal 11
45 Halted 0 ms 0 KB -