QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#598678 | #7184. Transport Pluses | xuanbac05 | WA | 0ms | 3904kb | C++17 | 3.0kb | 2024-09-28 22:56:47 | 2024-09-28 22:56:51 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define endl '\n'
#define MASK(i) (1LL << (i))
#define ull unsigned long long
#define ld long double
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define BIT(x , i) ((x >> (i)) & 1)
#define TASK "task"
#define sz(s) (int) (s).size()
using namespace std;
const int mxN = 5e5 + 227;
const int inf = 1e9 + 277;
const int mod = 1e9 + 7;
const ll infll = 1e18 + 7;
const int base = 307;
const int LOG = 20;
template <typename T1, typename T2> bool minimize(T1 &a, T2 b) {
if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maximize(T1 &a, T2 b) {
if (a < b) {a = b; return true;} return false;
}
struct Trace{
int id, x, y;
};
int n;
double t;
pair<int, int> sta, fin, a[mxN];
double getDist(int x, int y, int u, int v) {
return sqrt(1LL * (x - u) * (x - u) + 1LL * (y - v) * (y - v));
}
void solve()
{
cin >> n >> t >> sta.fi >> sta.se >> fin.fi >> fin.se;
for (int i = 1; i <= n; i++) {
cin >> a[i].fi >> a[i].se;
}
double res = getDist(sta.fi, sta.se, fin.fi, fin.se);
vector<Trace> trace;
for (int i = 1; i <= n; i++) {
for (int d1 = 0; d1 < 2; d1++)
for (int d2 = 0; d2 < 2; d2++) {
int x = (d1 == 0 ? sta.fi : a[i].fi);
int y = (d1 == 0 ? a[i].se : sta.se);
int u = (d2 == 0 ? a[i].fi : fin.fi);
int v = (d2 == 0 ? fin.se : a[i].se);
if (minimize(res, getDist(sta.fi, sta.se, x, y) + getDist(u, v, fin.fi, fin.se) + t) == true) {
trace.clear();
trace.pb({0, x, y});
trace.pb({i, u, v});
trace.pb({0, fin.fi, fin.se});
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (i == j) continue;
for (int d1 = 0; d1 < 2; d1++)
for (int d2 = 0; d2 < 2; d2++) {
int x = (d1 == 0 ? sta.fi : a[i].fi);
int y = (d1 == 0 ? a[i].se : sta.se);
int u = (d2 == 0 ? a[j].fi : fin.fi);
int v = (d2 == 0 ? fin.se : a[j].se);
if (minimize(res, getDist(sta.fi, sta.se, x, y) + t + t + getDist(u, v, fin.fi, fin.se)) == true) {
trace.clear();
trace.pb({0, x, y});
trace.pb({i, a[i].fi, a[j].se});
trace.pb({j, u, v});
trace.pb({0, fin.fi, fin.se});
}
}
}
}
cout << fixed << setprecision(6) << res << endl;
cout << sz(trace) << endl;
for (auto it : trace) cout << it.id << " " << it.x << " " << it.y << endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
// freopen(TASK".inp" , "r" , stdin);
// freopen(TASK".out" , "w" , stdout);
int tc = 1;
//cin >> tc;
while(tc--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3732kb
input:
1 2 1 1 5 3 6 2
output:
4.000000 3 0 1 2 1 6 3 0 5 3
result:
ok correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
2 1 1 1 6 1 1 3 6 3
output:
2.000000 4 0 1 1 1 1 3 2 6 1 0 6 1
result:
ok correct
Test #3:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
0 0 1 1 1 1
output:
0.000000 0
result:
ok correct
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3904kb
input:
0 0 100 100 0 0
output:
141.421356 0
result:
wrong answer arrived at (100.000000, 100.000000) instead of (0.000000, 0.000000)