답안 #574036

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
574036 2022-06-07T15:38:25 Z PedroBigMan Sky Walking (IOI19_walk) C++14
33 / 100
174 ms 21648 KB
/*
Author of all code: Pedro BIGMAN Dias
Last edit: 15/02/2021
*/
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
#include "walk.h"
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl
#define INF 1000000000000000000LL
#define EPS ((ld)0.00000000001)
#define pi ((ld)3.141592653589793)
#define VV(vvvv,NNNN,xxxx); REP(iiiii,0,NNNN) {vvvv.pb(xxxx);}
ll mod=1000000007LL;

template<class A=ll> 
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}

template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}} 

ll min_distance(vector<int> x, vector<int> h, vector<int> l, vector<int> r, vector<int> y, int s, int g) 
{
 	ll N = x.size(); ll M = l.size();
	vector<vector<ll> > be,en; VV(be,N,{}); VV(en,N,{});
	REP(i,0,M) {be[l[i]].pb(y[i]); en[r[i]].pb(y[i]);}
	be[N-1].pb(0); en[0].pb(0); 
	set<pl> active; //{height,min_dist} 
	active.insert({0LL,0LL});
	set<pl>::iterator under,over; ll d_under,d_over;
	ll he,L; vector<pl> newval;
	REP(i,0,N)
	{
		newval.clear();
		REP(j,0,be[i].size())
		{
			he=be[i][j]; L=h[i];
			under = active.lower_bound({he,0LL}); if(under==active.begin()) {d_under=INF;} else {under--; d_under=he-under->ff + under->ss;}
			over = active.lower_bound({he,0LL}); if(over==active.end()) {d_over=INF;} else{d_over=over->ff-he+over->ss;}
			if(min<ll>(d_over,d_under)<INF) {newval.pb({he,min<ll>(d_over,d_under)});}
		}
		REP(j,0,en[i].size())
		{
			if(active.lower_bound({en[i][j],0LL})==active.end()) {continue;}
			active.erase(active.lower_bound({en[i][j],0LL}));
		}
		REP(j,0,newval.size()) {active.insert(newval[j]);}
 	}
	if(active.size()==0) {return -1LL;} else {return ((active.begin())->ss + x[N-1]-x[0]);}
}

Compilation message

walk.cpp:5: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    5 | #pragma GCC optimization ("O3")
      | 
walk.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    6 | #pragma GCC optimization ("unroll-loops")
      | 
walk.cpp: In function 'll min_distance(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, int, int)':
walk.cpp:58:8: warning: variable 'L' set but not used [-Wunused-but-set-variable]
   58 |  ll he,L; vector<pl> newval;
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 3844 KB Output is correct
2 Correct 90 ms 5344 KB Output is correct
3 Correct 96 ms 6448 KB Output is correct
4 Correct 136 ms 13756 KB Output is correct
5 Correct 174 ms 18948 KB Output is correct
6 Correct 156 ms 16168 KB Output is correct
7 Correct 75 ms 10884 KB Output is correct
8 Correct 85 ms 15488 KB Output is correct
9 Correct 166 ms 17592 KB Output is correct
10 Correct 89 ms 16844 KB Output is correct
11 Correct 13 ms 4720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 3844 KB Output is correct
2 Correct 90 ms 5344 KB Output is correct
3 Correct 96 ms 6448 KB Output is correct
4 Correct 136 ms 13756 KB Output is correct
5 Correct 174 ms 18948 KB Output is correct
6 Correct 156 ms 16168 KB Output is correct
7 Correct 75 ms 10884 KB Output is correct
8 Correct 85 ms 15488 KB Output is correct
9 Correct 166 ms 17592 KB Output is correct
10 Correct 89 ms 16844 KB Output is correct
11 Correct 13 ms 4720 KB Output is correct
12 Correct 94 ms 6520 KB Output is correct
13 Correct 92 ms 13512 KB Output is correct
14 Correct 174 ms 20228 KB Output is correct
15 Correct 110 ms 13828 KB Output is correct
16 Correct 115 ms 14152 KB Output is correct
17 Correct 114 ms 13928 KB Output is correct
18 Correct 111 ms 15368 KB Output is correct
19 Correct 106 ms 15424 KB Output is correct
20 Correct 80 ms 12612 KB Output is correct
21 Correct 26 ms 8952 KB Output is correct
22 Correct 104 ms 13128 KB Output is correct
23 Correct 100 ms 15652 KB Output is correct
24 Correct 91 ms 16976 KB Output is correct
25 Correct 89 ms 15532 KB Output is correct
26 Correct 95 ms 19324 KB Output is correct
27 Correct 159 ms 21648 KB Output is correct
28 Correct 77 ms 17092 KB Output is correct
29 Correct 162 ms 19872 KB Output is correct
30 Correct 68 ms 13600 KB Output is correct
31 Correct 167 ms 21280 KB Output is correct
32 Correct 79 ms 17348 KB Output is correct
33 Correct 87 ms 18988 KB Output is correct
34 Correct 92 ms 18348 KB Output is correct
35 Correct 90 ms 17088 KB Output is correct
36 Correct 75 ms 16372 KB Output is correct
37 Correct 68 ms 14732 KB Output is correct
38 Correct 83 ms 18232 KB Output is correct
39 Correct 131 ms 20020 KB Output is correct
40 Correct 92 ms 17696 KB Output is correct
41 Correct 69 ms 15824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -