Submission #103812

#TimeUsernameProblemLanguageResultExecution timeMemory
103812ShtefSvjetlost (COI18_svjetlost)C++14
40 / 100
3035 ms7796 KiB
#include <iostream>
#include <utility>
#include <cmath>
#include <iomanip>
#include <vector>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair <ll, ll> pll;
#define x first
#define y second
#define mp make_pair

int n, q, dosad[200005];
vector <pll> a, b;

ld duljina(pll x, pll y){
	ld ret = sqrt((x.x - y.x) * (x.x - y.x) + (x.y - y.y) * (x.y - y.y));
	return ret;
}

ll crossprod(pll px1, pll py1, pll px2, pll py2){
	ll x1 = py1.x - px1.x;
	ll y1 = py1.y - px1.y;
	ll x2 = py2.x - px2.x;
	ll y2 = py2.y - px2.y;
	ll ret = x1 * y2 - x2 * y1;
	return ret;
}

void solve(){
	n = (int)a.size();
	b = a;
	for(int i = 0 ; i < n ; ++i){
		a.push_back(a[i]);
	}
	int j = 1;
	ld sad = duljina(a[0], a[1]), sol = 0;
	for(int i = 0 ; i < n ; ++i){
		//cout << i << ": ";
		while(crossprod(a[i], a[i + 1], a[j], a[j + 1]) > 0 && j < 2 * n){
			//cout << j << "-";
			sad += duljina(a[j], a[j + 1]);
			j++;
		}
		//cout << j << endl;
		sol = max(sol, sad);
		sad -= duljina(a[i], a[i + 1]);
	}
	cout << fixed << setprecision(10) << sol << endl;
	a = b;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
int m = n;
for(int i = 0 ; i < n ; ++i){
	int x, y;
	cin >> x >> y;
	a.push_back(mp(x, y));
}
cin >> q;
solve();
for(int i = 0 ; i < q ; ++i){
	int x;
	cin >> x;
	--x;
	a.erase(a.begin() + x - dosad[x]);
	for(int j = x ; j <= m ; ++j){
		dosad[j]++;
	}
	solve();
}

return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...