QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#137906#6725. Pick UpYarema#TL 0ms3788kbC++171.8kb2023-08-10 18:54:492023-08-10 18:54:52

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 18:54:52]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3788kb
  • [2023-08-10 18:54:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FILL(a, b) memset(a, b, sizeof(a))

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

struct point
{
	LL x, y;
	
	point() {}
	point(int a, int b): x(a), y(b) {}
	
	LL dis(point p)
	{
		return abs(x - p.x) + abs(y - p.y);
	}
};

point A, B, C;
double a, b;
int p = 0;
double ans[100447];

double f(point X)
{
	double d1 = A.dis(X) / a;
	double d2 = B.dis(X) / b;
	double d3 = C.dis(X) / b;
	return max(d1, d2) + d3;
}

double ter(double x)
{
	int ly = min({A.y, B.y, C.y}), ry = max({A.y, B.y, C.y});
	double res = 2e9;
	while (ly + 4 < ry)
	{
		int d = (ry - ly) / 2;
		int m1 = ly + d;
		int m2 = ly + d + 1;
		double f1 = f(point(x, m1));
		double f2 = f(point(x, m2));
		res = min({res, f1, f2});
		
		if (f1 < f2)
			ry = m2;
		else
			ly = m1;
	}
	FOR (i, ly, ry + 1)
		res = min(res, f(point(x, i)));
	ans[p] = min(ans[p], res);
	return res;
}


void solve()
{
	cin >> a >> b;
	cin >> A.x >> A.y;
	cin >> B.x >> B.y;
	cin >> C.x >> C.y;
	ans[p] = A.dis(C) / a;
	int lx = min({A.x, B.x, C.x}), rx = max({A.x, B.x, C.x});
	while (lx + 4 < rx)
	{
		int d = (rx - lx) / 2;
		int m1 = lx + d;
		int m2 = lx + d + 1;
		if (ter(m1) < ter(m2))
			rx = m2;
		else
			lx = m1;
	}
	FOR (i, lx, rx + 1)
		ter(i);
	p++;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int t;
	cin >> t;
	FOR (tt, 0, t)
	{
		solve();
	}
	cout << fixed << setprecision(7);
	FOR (i, 0, t) cout << ans[i] << '\n';
	
	
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3788kb

input:

3
1 2
0 2 1 0 2 2
1 3
1 1 0 1 3 1
1 2
0 0 100 100 1 1

output:

1.5000000
1.0000000
2.0000000

result:

ok 3 numbers

Test #2:

score: -100
Time Limit Exceeded

input:

100000
158260522 877914575
602436426 24979445 861648772 623690081 433933447 476190629
731963982 822804784
450968417 430302156 982631932 161735902 880895728 923078537
317063340 492686568
773361868 125660016 650287940 839296263 462224593 492601449
576823355 782177068
404011431 818008580 954291757 1604...

output:


result: