QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211610#7184. Transport PlusesjeanWA 0ms3932kbC++142.6kb2023-10-12 19:19:562023-10-12 19:19:56

Judging History

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

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

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 << 1 << "\n";
		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 << " " << h.x << " " << p[i].y << "\n";
					cout << i << " " << p[i].x << " " << p[j].y << "\n"; 
				}
				else {
					cout << 0 << " " << p[i].x << " " << h.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;
}

详细

Test #1:

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

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: 0
Accepted
time: 0ms
memory: 3928kb

input:

2 1
1 1
6 1
1 3
6 3

output:

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

result:

ok correct

Test #3:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

0 0
1 1
1 1

output:

0
1
0 1 1

result:

ok correct

Test #4:

score: 0
Accepted
time: 0ms
memory: 3928kb

input:

0 0
100 100
0 0

output:

141.421
1
0 0 0

result:

ok correct

Test #5:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

1 0
100 100
0 0
100 100

output:

100
3
0 100 100
1 0 100
0 0 0

result:

ok correct

Test #6:

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

input:

1 0
100 100
0 0
100 0

output:

0
3
0 0 100
1 0 0
0 0 0

result:

wrong answer step 2: source (0.000000, 100.000000) not on plus (100.000000, 0.000000)