QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#211605#7184. Transport PlusesjeanWA 0ms3928kbC++142.6kb2023-10-12 19:15:082023-10-12 19:15:08

Judging History

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

  • [2023-10-12 19:15:08]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3928kb
  • [2023-10-12 19:15:08]
  • 提交

answer

#include"bits/stdc++.h"

using namespace std;

const int N = 1e3 + 10;

int n, t;

struct node {
	double x, y;
}p[N], h, e;

double dis(node a, node b) {
	return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

double dist[N][N];

void solve() {
	cin >> n >> t;
	cin >> h.x >> h.y;
	cin >> e.x >> e.y;
	for(int i = 1; i <= n; i++) {
		cin >> p[i].x >> p[i].y;
	}
	
	double ans = dis(h, e);

	for(int i = 1; i <= n; i++) {
		double now = min(abs(p[i].x - h.x), abs(p[i].y - h.y));
		now += min(abs(p[i].x - e.x), abs(p[i].y - e.y));
		now += t;
		ans = min(ans, now);
	}
	
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			if(i == j) continue;
			double now = min(abs(p[i].x - h.x), abs(p[i].y - h.y));
			now += min(abs(p[j].x - e.x), abs(p[j].y - e.y));
			now += 2 * t;
			ans = min(ans, now);
		}
	}

	cout << ans << "\n";
	
	if(ans == dis(h, e)) {
		cout << 0 << " " << e.x << " " << e.y << "\n";
		return;
	}

	for(int i = 1; i <= n; i++) {
		double now = min(abs(p[i].x - h.x), abs(p[i].y - h.y));
		now += min(abs(p[i].x - e.x), abs(p[i].y - e.y));
		now += t;
		if(ans == now) {
			cout << 3 << "\n";
			if(abs(p[i].x - h.x) < abs(p[i].y - h.y)) cout << 0 << " " << p[i].y << " " << h.y << "\n";
			else cout << 0 << " " << h.x << " " << p[i].y << "\n";
			if(abs(p[i].x - e.x) < abs(p[i].y - e.y)) {
				cout << i << " " << p[i].x << " " << e.y << "\n";
				cout << 0 << " " << e.x << " " << e.y << "\n"; 
			}
			else{
				cout << i << " " << e.x << " " << p[i].y << "\n";
				cout << 0 << " " << e.x << " " << e.y << "\n";
			}
			return ;
		}
	}
	
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			if(i == j) continue;
			double now = min(abs(p[i].x - h.x), abs(p[i].y - h.y));
			now += min(abs(p[j].x - e.x), abs(p[j].y - e.y));
			now += 2 * t;
			if(now == ans) {
				cout << 4 << "\n";
				if(abs(p[i].x - h.x) > abs(p[i].y - h.y)) {
					cout << 0 << " " << p[i].x << " " << h.y << "\n";
					cout << i << " " << p[i].x << " " << p[j].y << "\n"; 
				}
				else {
					cout << 0 << " " << h.x << " " << p[i].y << "\n";
					cout << i << " " << p[i].x << " " << p[j].y << "\n";
				}
				if(abs(p[j].x - e.x) < abs(p[j].y - e.y)) {
					cout << j << " " << p[j].x << " " << e.y << "\n";
					cout << 0 << " " << e.x << " " << e.y << "\n";
				}
				else {
					cout << j << " " << e.x << " " << p[j].y << "\n";
					cout << 0 << " " << e.x << " " << e.y << "\n";
				}
				return ;
			}
		}
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1 2
1 1
5 3
6 2

output:

4
3
0 1 2
1 5 2
0 5 3

result:

ok correct

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3928kb

input:

2 1
1 1
6 1
1 3
6 3

output:

2
4
0 1 3
1 1 3
2 6 1
0 6 1

result:

wrong answer claimed 2.0000000000, actual 4.0000000000