QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#219900#7184. Transport PlusesxuxubaobaoWA 9ms7748kbC++172.0kb2023-10-19 19:35:252023-10-19 19:35:25

Judging History

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

  • [2023-10-19 19:35:25]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:7748kb
  • [2023-10-19 19:35:25]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using PII = pair<int,int>;
using ll = long long;

constexpr int N = 2e6 + 10;

map<array<int,2>,vector<array<int,4>>> q;

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, -1, 1};
int dis[110][110];
int vis[110][110];

map<array<int,2>,array<int,3>> pre;

void solve() {
	int n, t;
	cin >> n >> t;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	for(int i = 1; i <= n; i ++) {
		int x, y;
		cin >> x >> y;
		for(int j = 1; j <= 100; j ++) {
			for(int p = 1; p <= 100; p ++) {
				q[{x, j}].push_back({x, p, t, i});
				q[{x, j}].push_back({p, y, t, i});
				q[{j, y}].push_back({x, p, t, i});
				q[{j, y}].push_back({p, y, t, i});
			}
		}
	}
	for(int i = 1; i <= 100; i ++) {
		for(int j = 1; j <= 100; j ++) {
			for(int p = 0; p < 4; p ++) {
				int px = i + dx[p], py = j + dy[p];
				if(px < 1 || py < 1) continue;
				if(px > 100 || py > 100) continue;
				q[{i, j}].push_back({px, py, 1, 0});
			}
		}
	}
	double ans = sqrt(1ll * (x2 - x1) * (x2 - x1) + 1ll * (y2 - y1) * (y2 - y1));
	priority_queue<array<int,3>,vector<array<int,3>>,greater<array<int,3>>> p;
	memset(dis, 0x3f, sizeof dis);
	p.push({0, x1, y1});
	while(p.size()) {
		auto [w1, x1, y1] = p.top();
		p.pop();
		if(vis[x1][y1]) continue;
		vis[x1][y1] = 1;
		for(auto [x2, y2, w2, id] : q[{x1, y1}]) {
			if(dis[x2][y2] > w1 + w2) {
				pre[{x2,y2}] = {x1,y1, id};
				dis[x2][y2] = w1 + w2;
				p.push({w1 + w2, x2, y2});
			}
		}
	}
	double x = dis[x2][y2];
	if(ans < x) {
		cout << ans << "\n";
		cout << 1 << "\n";
		cout << 0 << " " << x2 << " " << y2 << "\n";
	}
	else {
		vector<array<int,3>> k;
		int lx = x2, rx = y2;
		while(lx != y1 || rx != y1) {
			auto [lg, rg, id] = pre[{lx, rx}];
			k.push_back({lx, rx, id});
			lx = lg, rx = rg;
		}
		reverse(k.begin(), k.end());
		cout << x << "\n";
		cout << k.size() << "\n";
		for(auto [x, y, id] : k) {
			cout << id << " " << x << " " << y << "\n";
		}
	}
}

int main() {
	int t;
	t = 1;
	while(t --){
		solve();
	}
}

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 6804kb

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: 9ms
memory: 7748kb

input:

2 1
1 1
6 1
1 3
6 3

output:

2
2
1 1 3
2 6 1

result:

ok correct

Test #3:

score: 0
Accepted
time: 3ms
memory: 6064kb

input:

0 0
1 1
1 1

output:

0
1
0 1 1

result:

ok correct

Test #4:

score: 0
Accepted
time: 3ms
memory: 6124kb

input:

0 0
100 100
0 0

output:

141.421
1
0 0 0

result:

ok correct

Test #5:

score: -100
Wrong Answer
time: 5ms
memory: 6980kb

input:

1 0
100 100
0 0
100 100

output:

141.421
1
0 0 0

result:

wrong answer read 141.421356 but expected 100.000000, error = 41.421356