답안 #723956

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
723956 2023-04-14T14:15:09 Z alvingogo Sky Walking (IOI19_walk) C++14
24 / 100
4000 ms 472628 KB
#include "walk.h"
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define fs first
#define sc second
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
long long min_distance(vector<int> x, vector<int> h, vector<int> l, vector<int> r, vector<int> y, int S, int T) {
	int n=x.size(),m=l.size();
	vector<pair<int,int> > g(n);
	for(int i=0;i<n;i++){
		g[i]={h[i],i};
	}
	sort(g.begin(),g.end());
	vector<pair<pair<int,int>,int> > e(m);
	for(int i=0;i<m;i++){
		e[i]={{l[i],r[i]},y[i]};
	}
	sort(e.begin(),e.end(),[&](auto a,auto b){return a.sc<b.sc;});
	set<int> s;
	for(int i=0;i<n;i++){
		s.insert(i);
	}
	int dl=0;
	map<pair<int,int>,int> mp;
	int cnt=0;
	vector<vector<pair<int,int> > > re;
	re.reserve(2400000);
	for(int i=0;i<n;i++){
		mp[pii(i,0)]=cnt;
		cnt++;
		re.push_back(vector<pair<int,int> >());
	}
	for(int i=0;i<m;i++){
		while(dl<n && g[dl].fs<e[i].sc){
			s.erase(g[dl].sc);
			dl++;
		}
		int nw=-1;
		for(auto it=s.lower_bound(e[i].fs.fs);(*it)!=e[i].fs.sc;it++){
			if(nw==-1){
				if(mp.find({*it,e[i].sc})==mp.end()){
					mp[pii(*it,e[i].sc)]=cnt;
					cnt++;
					re.push_back(vector<pair<int,int> >());
				}
				nw=mp[pii(*it,e[i].sc)];
			}
			auto nxt=next(it);
			if(mp.find({*nxt,e[i].sc})==mp.end()){
				mp[pii(*nxt,e[i].sc)]=cnt;
				cnt++;
				re.push_back(vector<pair<int,int> >());
			}
			int to=mp[{*nxt,e[i].sc}],val=(x[*nxt]-(x[*it]));
			re[nw].push_back({to,val});
			re[to].push_back({nw,val});
			nw=to;
		}
	}
	pair<int,int> nwh={-1,0};
	for(auto h:mp){
		if(h.fs.sc){
			re[h.sc].push_back({nwh.fs,h.fs.sc-nwh.sc});
			re[nwh.fs].push_back({h.sc,h.fs.sc-nwh.sc});
		}
		nwh={h.sc,h.fs.sc};
	}
	vector<ll> dis(mp.size(),1e18);
	int st=mp[pii(S,0)],ed=mp[pii(T,0)];
	dis[st]=0;
	priority_queue<pair<ll,int>,vector<pair<ll,int> >,greater<pair<ll,int> > > pq;
	pq.push({0,st});
	while(pq.size()){
		auto c=pq.top();
		pq.pop();
		for(auto z:re[c.sc]){
			if(dis[z.fs]>c.fs+z.sc){
				dis[z.fs]=c.fs+z.sc;
				pq.push({dis[z.fs],z.fs});
			}
		}
	}
	if(dis[ed]>5e17){
		return -1;
	}
	return dis[ed];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1222 ms 121164 KB Output is correct
4 Correct 1319 ms 131648 KB Output is correct
5 Correct 890 ms 114988 KB Output is correct
6 Correct 801 ms 102064 KB Output is correct
7 Correct 910 ms 115284 KB Output is correct
8 Correct 1525 ms 155524 KB Output is correct
9 Correct 1014 ms 111756 KB Output is correct
10 Correct 1810 ms 182700 KB Output is correct
11 Correct 701 ms 64548 KB Output is correct
12 Correct 522 ms 45768 KB Output is correct
13 Correct 1578 ms 160348 KB Output is correct
14 Correct 354 ms 43476 KB Output is correct
15 Correct 389 ms 45268 KB Output is correct
16 Correct 383 ms 46600 KB Output is correct
17 Correct 459 ms 44896 KB Output is correct
18 Correct 293 ms 47552 KB Output is correct
19 Correct 12 ms 2388 KB Output is correct
20 Correct 126 ms 21964 KB Output is correct
21 Correct 475 ms 45056 KB Output is correct
22 Correct 500 ms 45316 KB Output is correct
23 Correct 355 ms 56072 KB Output is correct
24 Correct 437 ms 46240 KB Output is correct
25 Correct 469 ms 45176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 139 ms 13200 KB Output is correct
2 Execution timed out 4054 ms 472628 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 139 ms 13200 KB Output is correct
2 Execution timed out 4054 ms 472628 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1222 ms 121164 KB Output is correct
21 Correct 1319 ms 131648 KB Output is correct
22 Correct 890 ms 114988 KB Output is correct
23 Correct 801 ms 102064 KB Output is correct
24 Correct 910 ms 115284 KB Output is correct
25 Correct 1525 ms 155524 KB Output is correct
26 Correct 1014 ms 111756 KB Output is correct
27 Correct 1810 ms 182700 KB Output is correct
28 Correct 701 ms 64548 KB Output is correct
29 Correct 522 ms 45768 KB Output is correct
30 Correct 1578 ms 160348 KB Output is correct
31 Correct 354 ms 43476 KB Output is correct
32 Correct 389 ms 45268 KB Output is correct
33 Correct 383 ms 46600 KB Output is correct
34 Correct 459 ms 44896 KB Output is correct
35 Correct 293 ms 47552 KB Output is correct
36 Correct 12 ms 2388 KB Output is correct
37 Correct 126 ms 21964 KB Output is correct
38 Correct 475 ms 45056 KB Output is correct
39 Correct 500 ms 45316 KB Output is correct
40 Correct 355 ms 56072 KB Output is correct
41 Correct 437 ms 46240 KB Output is correct
42 Correct 469 ms 45176 KB Output is correct
43 Correct 139 ms 13200 KB Output is correct
44 Execution timed out 4054 ms 472628 KB Time limit exceeded
45 Halted 0 ms 0 KB -