Submission #529064

# Submission time Handle Problem Language Result Execution time Memory
529064 2022-02-22T05:01:27 Z yungyao Fences (JOI18_fences) C++17
0 / 100
1 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 = a, nb = b;
	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 * 6 + min(s * 2.0, abs(a - mkp(-s, s)) + abs(b - mkp(s, s)));
	//cout << '\n' << a.x << ',' << a.y << ' ' << b.x << ',' << b.y;
	//cout << '\n' << abs(a - mkp(-s, s)) + abs(b - mkp(s, s));
}

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

	solve();

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 0 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 0 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 0 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -