QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#281425 | #7184. Transport Pluses | ikaurov# | WA | 131ms | 4568kb | C++20 | 3.4kb | 2023-12-10 04:53:55 | 2023-12-10 04:53:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef long double ld;
const ld PI = acosl(-1);
const ll mod7 = 1e9 + 7;
const ll mod9 = 998244353;
const ll INF = 2 * 1024 * 1024 * 1023;
const char nl = '\n';
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define all(v) v.begin(),v.end()
#pragma GCC optimize("O2")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update>;
ll l, r, k, n, m, p, q, u, v, w, x, y, z;
string s, t;
vi d4x = {1, 0, -1, 0};
vi d4y = {0, 1, 0, -1};
vi d8x = {1, 0, -1, 0, 1, 1, -1, -1};
vi d8y = {0, 1, 0, -1, 1, -1, 1, -1};
bool multiTest = 0;
void solve(int tt) {
double cost;
cin >> n >> cost;
double dist[101][101];
forn(i, 101) forn(j, 101) dist[i][j] = 1e18;
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
int xStart = x1;
int yStart = y1;
dist[x1][y1] = 0;
vi covered[101][101];
vector<pii> points;
forn(i, n) {
cin >> x1 >> y1;
points.push_back({x1, y1});
forn(j, 101) {
covered[x1][j].push_back(i);
if(j != x1) covered[j][y1].push_back(i);
}
}
int visited[101][101];
memset(visited, 0, sizeof(visited));
array<int, 3> br[101][101];
double precomputeSqrt[20010];
for(int i = 1; i <= 20000; i++) {
precomputeSqrt[i] = sqrtl(i);
}
while(true) {
double bestDist = 1e18;
int curX = -1;
int curY = -1;
forn(i, 101) {
forn(j, 101) {
if(visited[i][j]) continue;
if(dist[i][j] < bestDist) {
bestDist = dist[i][j];
curX = i;
curY = j;
}
}
}
if(curX == -1) break;
forn(i, 101) {
forn(j, 101) {
double nextCost = precomputeSqrt[(curX - i) * (curX - i) + (curY - j) * (curY - j)];
if(dist[i][j] > bestDist + nextCost) {
dist[i][j] = bestDist + nextCost;
br[i][j] = {0, curX, curY};
}
}
}
for(int z : covered[curX][curY]) {
forn(i, 101) {
if(dist[points[z].first][i] > bestDist + cost) {
dist[points[z].first][i] = bestDist + cost;
br[points[z].first][i] = {z+1, curX, curY};
}
if(dist[i][points[z].second] > bestDist + cost) {
dist[i][points[z].second] = bestDist + cost;
br[i][points[z].second] = {z+1, curX, curY};
}
}
}
visited[curX][curY] = 1;
}
cout << dist[x2][y2] << nl;
int curX = x2;
int curY = y2;
vector<array<int, 3>> moves;
while(true) {
moves.push_back({br[curX][curY][0], curX, curY});
int prevX = curX;
curX = br[prevX][curY][1];
curY = br[prevX][curY][2];
if(curX == xStart && curY == yStart) break;
}
cout << moves.size() << nl;
reverse(all(moves));
for(auto z : moves) cout << z[0] << ' ' << z[1] << ' ' << z[2] << nl;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout << fixed << setprecision(14);
int t = 1;
if (multiTest) cin >> t;
for (int ii = 0; ii < t; ii++) {
solve(ii);
}
}
详细
Test #1:
score: 100
Accepted
time: 128ms
memory: 4480kb
input:
1 2 1 1 5 3 6 2
output:
4.00000000000000 3 0 1 2 1 5 2 0 5 3
result:
ok correct
Test #2:
score: 0
Accepted
time: 128ms
memory: 4424kb
input:
2 1 1 1 6 1 1 3 6 3
output:
2.00000000000000 2 1 0 3 2 6 1
result:
ok correct
Test #3:
score: -100
Wrong Answer
time: 131ms
memory: 4568kb
input:
0 0 1 1 1 1
output:
0.00000000000000 2 0 0 0 0 1 1
result:
wrong answer claimed 0.0000000000, actual 2.8284271247