QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#236471 | #7184. Transport Pluses | UFRJ# | WA | 3ms | 62448kb | C++20 | 4.4kb | 2023-11-03 23:53:06 | 2023-11-03 23:53:06 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
using lint = int64_t;
using dbl = double;
const int inf = numeric_limits<int>::max() / 4;
const int N = 100;
int same_plus[N+2][N+2][N+2][N+2];
int any_plus[N+2][N+2];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, t;
cin>>n>>t;
int xh, yh;
int xe, ye;
cin>>xh>>yh>>xe>>ye;
vector<pair<int, int>> plus(n);
for(int id = 0; id < n; id++){
auto &[x,y] = plus[id];
cin>>x>>y;
vector<pair<int, int>> v;
v.reserve(2*n);
for(int i =0; i<=N; i++){
v.emplace_back(i, y);
v.emplace_back(x, i);
}
for(auto [a, b] : v){
any_plus[a][b] = id + 1;
for(auto [c, d] : v){
same_plus[a][b][c][d] = id+1;
}
}
}
dbl ans = sqrtl((xh - xe)*(xh - xe) + (yh - ye)*(yh - ye));
for(int a = 0; a<=N; a++)
for(int b = 0; b <= N; b++)
for(int c = 0; c <= N; c++)
for(int d = 0; d <= N; d++){
if(!any_plus[a][b] || !any_plus[c][d]) continue;
int D = 2*t;
if(same_plus[a][b][c][d]) D = t;
if(a == c && b == d) D = 0;
dbl H = sqrtl((xh - a)*(xh - a) + (yh - b)*(yh - b));
if(same_plus[xh][yh][a][b]) H = min<dbl>(H, t);
dbl E = sqrtl((c - xe)*(c - xe) + (d - ye)*(d - ye));
if(same_plus[xe][ye][c][d]) E = min<dbl>(E, t);
dbl cur = H + D + E;
ans = min(ans, cur);
}
cout<<fixed<<setprecision(4)<<ans<<"\n";
for(int a = 0; a<=N; a++)
for(int b = 0; b <= N; b++)
for(int c = 0; c <= N; c++)
for(int d = 0; d <= N; d++){
if(!any_plus[a][b] || !any_plus[c][d]) continue;
int D = 2*t;
if(same_plus[a][b][c][d]) D = t;
if(a == c && b == d) D = 0;
dbl H = sqrtl((xh - a)*(xh - a) + (yh - b)*(yh - b));
if(same_plus[xh][yh][a][b]) H = min<dbl>(H, t);
dbl E = sqrtl((c - xe)*(c - xe) + (d - ye)*(d - ye));
if(same_plus[xe][ye][c][d]) E = min<dbl>(E, t);
dbl cur = H + D + E;
if(cur == ans){
vector<tuple<int, int, int>> answer;
if(H == t){
answer.emplace_back(same_plus[xh][yh][a][b], a, b);
}
else {
answer.emplace_back(0, a, b);
}
if(D == 2*t){
int P1 = any_plus[a][b];
int P2 = any_plus[c][d];
answer.emplace_back(P1, plus[P1].first, plus[P2].second);
answer.emplace_back(P2, plus[P2].first, plus[P2].second);
}
else if(D == t) {
answer.emplace_back(same_plus[a][b][c][d], c, d);
}
if(E == t){
answer.emplace_back(same_plus[c][d][xe][ye], xe, ye);
}
else {
answer.emplace_back(0, xe, ye);
}
{
int lx = xh, ly = yh;
vector<tuple<int, int, int>> fix;
for(auto [p, x, y] : answer){
if(lx != x || ly != y){
fix.emplace_back(p, x, y);
lx = x, ly = y;
}
}
answer = fix;
}
cout<<answer.size()<<"\n";
for(auto [p, x, y] : answer) cout<<p<<" "<<x<<" "<<y<<"\n";
return 0;
}
}
if(xe == xh && ye == yh){
cout<<"0\n";
} else {
cout<<"1\n";
cout<<"0 "<<xe<<" "<<ye<<"\n";
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 58660kb
input:
1 2 1 1 5 3 6 2
output:
4.0000 3 0 1 2 1 5 2 0 5 3
result:
ok correct
Test #2:
score: 0
Accepted
time: 3ms
memory: 62448kb
input:
2 1 1 1 6 1 1 3 6 3
output:
2.0000 2 1 0 3 2 6 1
result:
ok correct
Test #3:
score: 0
Accepted
time: 2ms
memory: 3788kb
input:
0 0 1 1 1 1
output:
0.0000 0
result:
ok correct
Test #4:
score: 0
Accepted
time: 2ms
memory: 3852kb
input:
0 0 100 100 0 0
output:
141.4214 1 0 0 0
result:
ok correct
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 47940kb
input:
1 0 100 100 0 0 100 100
output:
100.0000 2 1 0 100 1 0 0
result:
wrong answer step 2: target (0.000000, 0.000000) not on plus (100.000000, 100.000000)