QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#269280 | #7184. Transport Pluses | ideograph_advantage# | WA | 3ms | 4992kb | C++20 | 2.8kb | 2023-11-29 14:43:24 | 2023-11-29 14:43:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define iter(v) v.begin(), v.end()
#define SZ(v) int(v.size())
#define pb emplace_back
#define ff first
#define ss second
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U>
void debug(T a, U ... b){ cout << a << " ", debug(b...); }
template<class T> void pary(T l, T r){
while(l != r) cout << *l << " ", l++;
cout << endl;
}
#else
#define debug(...) void()
#define pary(...) void()
#endif
template<class A, class B>
ostream& operator<<(ostream& o, pair<A, B> p){
return o << '(' << p.ff << ',' << p.ss << ')';
}
using ld = double;
using edge = pair<int, double>;
using item = pair<double, int>;
#define X ff
#define Y ss
int getid(int x, int y){
return x * 101 + y;
}
int getid(pii c){
return getid(c.X, c.Y);
}
int getplus(int id){
return 101 * 101 + id;
}
ld dis(pii a, pii b){
ll dx = a.X - b.X, dy = a.Y - b.Y;
return sqrt(dx * dx + dy * dy);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, t;
cin >> n >> t;
pii H, E;
cin >> H.X >> H.Y;
cin >> E.X >> E.Y;
vector<vector<edge>> g(101 * 101 + n);
vector<pii> plus(n);
for(int i = 0; i < n; i++) cin >> plus[i].X >> plus[i].Y;
for(int x = 0; x <= 100; x++){
for(int y = 0; y <= 100; y++){
g[getid(x, y)].pb(edge(getid(E), dis(pii(x, y), E)));
g[getid(H)].pb(edge(getid(x, y), dis(H, pii(x, y))));
for(int i = 0; i < n; i++){
if(plus[i].X == x || plus[i].Y == y){
g[getid(x, y)].pb(edge(getplus(i), t));
g[getplus(i)].pb(edge(getid(x, y), 0));
}
else{
g[getid(x, y)].pb(edge(getid(plus[i].X, y), abs(plus[i].X - x)));
g[getid(x, y)].pb(edge(getid(x, plus[i].Y), abs(plus[i].Y - y)));
}
}
}
}
priority_queue<item, vector<item>, greater<>> pq;
pq.push(item(0, getid(H)));
vector<ld> dis(SZ(g), 1e9);
dis[getid(H)] = 0;
vector<bool> vis(SZ(g));
vector<int> from(SZ(g), -1);
while(!pq.empty()){
auto [d, now] = pq.top();
pq.pop();
if(vis[now]) continue;
vis[now] = true;
for(auto [v, w] : g[now]){
if(dis[now] + w >= dis[v]) continue;
dis[v] = dis[now] + w;
from[v] = now;
pq.push(item(dis[v], v));
}
}
int cur = getid(E);
vector<pii> ans;
int lstp = -1;
int lstplus = -1;
while(cur != -1){
if(cur < 101 * 101){
if(lstp != -1) ans.pb(pii(lstplus + 1, lstp));
lstp = cur;
lstplus = -1;
}
else{
lstplus = cur - 101 * 101;
}
cur = from[cur];
}
reverse(iter(ans));
cout << fixed << setprecision(20) << dis[getid(E)] << "\n";
for(auto [ty, id] : ans){
int x = id / 101, y = id % 101;
cout << ty << " " << x << " " << y << "\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 4992kb
input:
1 2 1 1 5 3 6 2
output:
4.00000000000000000000 0 1 2 1 5 2 0 5 3
result:
wrong answer arrived at (1.000000, 1.000000) instead of (5.000000, 3.000000)