답안 #529062

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
529062 2022-02-22T04:52:09 Z yungyao Fences (JOI18_fences) C++17
0 / 100
0 ms 204 KB
using namespace std;
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>

typedef long long LL;
typedef pair<int,int> pii;
#define pb push_back
#define mkp make_pair
#define F first
#define S second
#define iter(x) x.begin(),x.end()
#define REP(n) for (int __=n;__--;)
#define REP0(i, n) for (int i=0;i<n;++i)
#define REP1(i, n) for (int i=1;i<=n;++i)

const int maxn = 105, mod = 0;
const LL inf = 0;

#include <cmath>
typedef pair<double, double> poi;
#define x first
#define y second
poi operator-(poi a, poi b){
	return mkp(a.x - b.x, a.y - b.y);
}
poi operator+(poi a, poi b){
	return mkp(a.x + b.x, a.y + b.y);
}
poi operator*(poi a, double k){
	return mkp(a.x * k, a.y * k);
}
poi operator-(poi a){
	return mkp(-a.x, -a.y);
}
double dot(poi a, poi b){
	return a.x * b.x + a.y * b.y;
}
double cross(poi a, poi b){
	return a.x * b.y - b.x * a.y;
}
double abs2(poi a){
	return dot(a, a);
}
double abs(poi a){
	return sqrt(abs2(a));
}
/*
bool inseg(poi t, poi a, poi b){
	if (cross(a - t, b - t)) return false;
	return dot(a - t, b - t) <= 0;
}
bool intersect(poi a, poi b, poi c, poi d){
	if (inseg(a, c, d) or inseg(b, c, d) or inseg(c, a, b) or inseg(d, a, b)) return false;
	return ((cross(b - a, c - a) < 0) ^ (cross(b - a, d - a) < 0)) and ((cross(a - c, d - c) < 0) ^ (cross(b - c, d - c) < 0));
}*/
#include <iomanip>

void solve(){
	int n, s;
    poi	a, b;

	cin >> n >> s >> a.x >> a.y >> b.x >> b.y;
	if (dot(mkp(1, 1), a - b) < 0) swap(a, b);
	if (cross(mkp(1, 1), a - b) > 0){
		a = mkp(a.y, -a.x);
		b = mkp(b.y, -b.x);
	}
	if (a.x > b.x) swap(a, b);
	poi na, nb;
	if (a.x < -s) na = a + (b - a) * ((-s - a.x) / (b.x - a.x));
	if (b.x > s) nb = b + (a - b) * ((s - b.x) / (a.x - b.x));
	a = na; b = nb;
	if (a.y < 0){a = -a; b = -b;}
	cout << fixed << setprecision(15) << s * 8 + min(0.0, a.y + b.y - s*2 - abs(a.x - b.x));
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);

	solve();

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -