QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#137935#6725. Pick UpPetroTarnavskyi#AC ✓797ms3836kbC++171.5kb2023-08-10 19:11:022023-08-10 19:11:04

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 19:11:04]
  • 评测
  • 测评结果:AC
  • 用时:797ms
  • 内存:3836kb
  • [2023-08-10 19:11:02]
  • 提交

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;
typedef double db;


db dist(db x0, db y0, db x1, db y1, db v){
	return (abs(x0 - x1) + abs(y0 - y1)) / v;
} 

int xA, yA, xB, yB, xC, yC;
int a, b;

db d(db x, db y){
	return max(dist(xA, yA, x, y, a), dist(xB, yB, x, y, b)) + dist(x, y, xC, yC, b);
}

db checkY(db y){
	db Lx = min({xA, xB, xC}), Rx = max({xA, xB, xC});
	FOR(it, 0, 60){
		db m1x = (2 * Lx + Rx) / 3.0;
		db m2x = (Lx + 2 * Rx) / 3.0;
		
		if(d(m1x, y) > d(m2x, y))
			Lx = m1x;
		else
			Rx = m2x;
	}
	return d(Rx, y);
}


void solve(){
	scanf("%d%d", &a, &b);	
	scanf("%d%d%d%d%d%d", &xA, &yA, &xB, &yB, &xC, &yC);	

	
	db ans = dist(xA, yA, xC, yC, a);
	FOR(t, 0, 2){		
		ans = min(ans, checkY(yA));
		ans = min(ans, checkY(yB));
		ans = min(ans, checkY(yC));


		swap(xA, yA);
		swap(xB, yB);
		swap(xC, yC);
	}	
	printf("%.6lf\n", ans);
}

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


	int t;
	scanf("%d", &t);
	
	//cin >> t;
	
	while(t--)
		solve();
		
	//cerr << 1.0 * clock() / CLOCKS_PER_SEC << endl;
	
	
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3836kb

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.500000
1.000000
2.000000

result:

ok 3 numbers

Test #2:

score: 0
Accepted
time: 797ms
memory: 3772kb

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:

1.384607
1.178237
1.744617
0.470200
1.370533
2.305183
1.061125
1.061637
1.235959
2.333838
2.000607
0.977253
0.624150
1.185363
0.140506
0.180123
1.226313
5.927497
5.952019
0.495850
1.337810
1.428638
1.169260
68.941145
2.424190
1.917162
3.668087
0.154011
2.823961
1.122422
1.137973
0.964164
1.472172
0....

result:

ok 100000 numbers