QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#199403 | #7184. Transport Pluses | kiwiHM# | RE | 82ms | 65928kb | C++20 | 4.0kb | 2023-10-04 11:35:23 | 2023-10-04 11:35:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 125;
const int N = 102;
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
struct node{
int x, y;
bool operator != (const node p){
return x != p.x || y != p.y;
}
} crs[Maxn], S, T;
int n, t;
int encoder(int x, int y){
return x * N + y;
}
int encoder(node x){
return encoder(x.x, x.y);
}
node decoder(int id){
int x = id / N;
int y = id - x * N;
return (node) {x, y};
}
double sqr(int x){ return x * x; }
double getEdis(node A, node B){
return sqrt(sqr(A.x - B.x) + sqr(A.y - B.y));
}
struct Dijkstra{
#define MaxN 50050
#define MaxM 2000500
struct Qnode{
int u, d;
bool operator < (const Qnode p)const {
return d < p.d;
}
bool operator > (const Qnode p)const {
return d > p.d;
}
};
priority_queue <Qnode, vector<Qnode>, greater<Qnode> > que;
struct Edge{
int v, w, eid, next;
} edge[MaxM << 1];
int first[MaxN], dis[MaxN], frm[MaxN], fwhich[MaxN], Top;
void init(){
Top = 1;
memset(first, 0, sizeof first);
}
void add(int u, int v, int w, int eid = 0){
edge[++Top] = (Edge) {v, w, eid, first[u]};
first[u] = Top;
}
int dijkstra(int S, int T){
memset(dis, 63, sizeof dis);
while (que.size()) que.pop();
dis[S] = 0, que.push((Qnode) {S, 0});
while (que.size()){
int u = que.top().u, d = que.top().d; que.pop();
if (d > dis[u]) continue;
for (int i = first[u]; i; i = edge[i].next){
int v = edge[i].v, w = edge[i].w, eid = edge[i].eid;
if (dis[v] == -1 || d + w < dis[v]){
dis[v] = d + w;
frm[v] = u;
fwhich[v] = eid;
que.push((Qnode) {v, dis[v]});
}
}
}
return dis[T];
}
} G;
void build(){
G.init();
for (int i = 0; i <= 100; i++)
for (int j = 0; j <= 100; j++)
for (int k = 0; k < 4; k++){
int tx = i + dx[k];
int ty = j + dy[k];
if (tx < 0 || ty < 0 || tx > 100 || ty > 100)
continue;
G.add(encoder(i, j), encoder(tx, ty), 1);
}
for (int id = 1; id <= n; id++){
int x = crs[id].x, y = crs[id].y;
vector <int> vec; vec.clear();
vec.push_back(encoder(x, y));
for (int i = 0; i <= 100; i++){
if (i != x) vec.push_back(encoder(i, y));
if (i != y) vec.push_back(encoder(x, i));
}
for (int i = 0, si = vec.size(); i < si; i++)
for (int j = i + 1; j < si; j++){
G.add(vec[i], vec[j], t, id);
G.add(vec[j], vec[i], t, id);
}
}
}
int main(){
ios :: sync_with_stdio(false), cin.tie(0);
cin >> n >> t;
cin >> S.x >> S.y >> T.x >> T.y;
for (int i = 1; i <= n; i++)
cin >> crs[i].x >> crs[i].y;
build();
double dis1 = G.dijkstra(encoder(S), encoder(T));
double dis2 = getEdis(S, T);
if (dis1 < dis2){
cout << fixed << setprecision(10) << dis1 << endl;
vector <node> ansnode; ansnode.clear();
vector <int> ansedge; ansedge.clear();
for (node cur = T; cur != S; cur = decoder(G.frm[encoder(cur)])){
ansnode.push_back(cur);
ansedge.push_back(G.fwhich[encoder(cur)]);
}
reverse(ansnode.begin(), ansnode.end());
reverse(ansedge.begin(), ansedge.end());
cout << ansnode.size() << endl;
for (int i = 0, si = ansnode.size(); i < si; i++)
cout << ansedge[i] << ' ' << ansnode[i].x << ' ' << ansnode[i].y << endl;
} else {
cout << fixed << setprecision(10) << dis2 << endl;
cout << 1 << endl;
cout << "0 " << T.x << ' ' << T.y << endl;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 7336kb
input:
1 2 1 1 5 3 6 2
output:
4.0000000000 3 0 1 2 1 6 3 0 5 3
result:
ok correct
Test #2:
score: 0
Accepted
time: 2ms
memory: 6128kb
input:
2 1 1 1 6 1 1 3 6 3
output:
2.0000000000 2 1 38 3 2 6 1
result:
ok correct
Test #3:
score: 0
Accepted
time: 1ms
memory: 4868kb
input:
0 0 1 1 1 1
output:
0.0000000000 1 0 1 1
result:
ok correct
Test #4:
score: 0
Accepted
time: 2ms
memory: 6884kb
input:
0 0 100 100 0 0
output:
141.4213562373 1 0 0 0
result:
ok correct
Test #5:
score: 0
Accepted
time: 0ms
memory: 7336kb
input:
1 0 100 100 0 0 100 100
output:
100.0000000000 101 1 0 100 0 0 99 0 0 98 0 0 97 0 0 96 0 0 95 0 0 94 0 0 93 0 0 92 0 0 91 0 0 90 0 0 89 0 0 88 0 0 87 0 0 86 0 0 85 0 0 84 0 0 83 0 0 82 0 0 81 0 0 80 0 0 79 0 0 78 0 0 77 0 0 76 0 0 75 0 0 74 0 0 73 0 0 72 0 0 71 0 0 70 0 0 69 0 0 68 0 0 67 0 0 66 0 0 65 0 0 64 0 0 63 0 0 62 0 0 61 ...
result:
ok correct
Test #6:
score: 0
Accepted
time: 0ms
memory: 6604kb
input:
1 0 100 100 0 0 100 0
output:
0.0000000000 1 1 0 0
result:
ok correct
Test #7:
score: 0
Accepted
time: 2ms
memory: 7460kb
input:
1 0 100 100 0 0 0 100
output:
0.0000000000 1 1 0 0
result:
ok correct
Test #8:
score: 0
Accepted
time: 2ms
memory: 6912kb
input:
1 100 50 50 0 0 50 50
output:
70.7106781187 1 0 0 0
result:
ok correct
Test #9:
score: 0
Accepted
time: 0ms
memory: 6812kb
input:
1 100 50 50 0 0 0 50
output:
70.7106781187 1 0 0 0
result:
ok correct
Test #10:
score: 0
Accepted
time: 2ms
memory: 7484kb
input:
1 100 50 50 0 0 51 51
output:
70.7106781187 1 0 0 0
result:
ok correct
Test #11:
score: 0
Accepted
time: 0ms
memory: 7328kb
input:
1 100 50 50 0 0 2 53
output:
70.7106781187 1 0 0 0
result:
ok correct
Test #12:
score: 0
Accepted
time: 0ms
memory: 5564kb
input:
1 100 0 0 100 100 50 50
output:
141.4213562373 1 0 100 100
result:
ok correct
Test #13:
score: 0
Accepted
time: 2ms
memory: 6792kb
input:
1 33 0 0 100 100 50 50
output:
133.0000000000 101 0 0 1 0 0 2 0 0 3 0 0 4 0 0 5 0 0 6 0 0 7 0 0 8 0 0 9 0 0 10 0 0 11 0 0 12 0 0 13 0 0 14 0 0 15 0 0 16 0 0 17 0 0 18 0 0 19 0 0 20 0 0 21 0 0 22 0 0 23 0 0 24 0 0 25 0 0 26 0 0 27 0 0 28 0 0 29 0 0 30 0 0 31 0 0 32 0 0 33 0 0 34 0 0 35 0 0 36 0 0 37 0 0 38 0 0 39 0 0 40 0 0 41 0 0...
result:
ok correct
Test #14:
score: 0
Accepted
time: 2ms
memory: 6784kb
input:
1 12 100 0 11 90 0 100
output:
122.0000000000 111 0 99 0 0 98 0 0 97 0 0 96 0 0 95 0 0 94 0 0 93 0 0 92 0 0 91 0 0 90 0 0 89 0 0 88 0 0 87 0 0 86 0 0 85 0 0 84 0 0 83 0 0 82 0 0 81 0 0 80 0 0 79 0 0 78 0 0 77 0 0 76 0 0 75 0 0 74 0 0 73 0 0 72 0 0 71 0 0 70 0 0 69 0 0 68 0 0 67 0 0 66 0 0 65 0 0 64 0 0 63 0 0 62 0 0 61 0 0 60 0 0...
result:
ok correct
Test #15:
score: 0
Accepted
time: 0ms
memory: 6460kb
input:
1 12 100 0 10 89 0 100
output:
122.0000000000 111 0 99 0 0 98 0 0 97 0 0 96 0 0 95 0 0 94 0 0 93 0 0 92 0 0 91 0 0 90 0 0 89 0 0 88 0 0 87 0 0 86 0 0 85 0 0 84 0 0 83 0 0 82 0 0 81 0 0 80 0 0 79 0 0 78 0 0 77 0 0 76 0 0 75 0 0 74 0 0 73 0 0 72 0 0 71 0 0 70 0 0 69 0 0 68 0 0 67 0 0 66 0 0 65 0 0 64 0 0 63 0 0 62 0 0 61 0 0 60 0 0...
result:
ok correct
Test #16:
score: 0
Accepted
time: 2ms
memory: 9420kb
input:
2 1 2 1 5 1 1 3 6 3
output:
3.0000000000 1 0 5 1
result:
ok correct
Test #17:
score: 0
Accepted
time: 2ms
memory: 7148kb
input:
2 2 2 1 5 1 1 3 6 3
output:
3.0000000000 1 0 5 1
result:
ok correct
Test #18:
score: 0
Accepted
time: 0ms
memory: 5564kb
input:
1 2 1 1 5 3 7 2
output:
4.0000000000 3 0 1 2 1 5 2 0 5 3
result:
ok correct
Test #19:
score: 0
Accepted
time: 0ms
memory: 7280kb
input:
1 2 1 1 5 4 6 2
output:
4.0000000000 3 0 1 2 1 6 4 0 5 4
result:
ok correct
Test #20:
score: 0
Accepted
time: 3ms
memory: 15780kb
input:
12 1 77 80 76 78 77 81 76 79 77 78 75 80 75 79 76 80 78 81 77 81 76 81 76 80 77 79 76 79
output:
1.0000000000 1 10 76 78
result:
ok correct
Test #21:
score: 0
Accepted
time: 3ms
memory: 9204kb
input:
5 1 40 69 37 71 37 69 36 71 38 70 40 72 40 71
output:
1.0000000000 1 5 37 71
result:
ok correct
Test #22:
score: 0
Accepted
time: 4ms
memory: 10528kb
input:
8 1 84 27 86 32 85 31 83 27 86 27 85 28 83 27 83 32 85 31 87 29
output:
1.0000000000 1 3 86 32
result:
ok correct
Test #23:
score: 0
Accepted
time: 7ms
memory: 13240kb
input:
11 1 95 30 99 36 96 33 95 36 94 30 98 33 98 36 97 31 99 33 99 31 98 35 95 36 100 32
output:
1.0000000000 1 10 99 36
result:
ok correct
Test #24:
score: 0
Accepted
time: 0ms
memory: 9456kb
input:
4 1 19 37 18 32 18 36 21 36 19 33 22 34
output:
2.0000000000 2 0 18 37 1 18 32
result:
ok correct
Test #25:
score: 0
Accepted
time: 4ms
memory: 11524kb
input:
7 1 49 6 48 8 46 3 49 9 45 6 43 3 49 8 43 8 48 2
output:
1.0000000000 1 5 48 8
result:
ok correct
Test #26:
score: 0
Accepted
time: 0ms
memory: 13040kb
input:
10 0 75 31 74 34 77 36 79 34 74 37 75 32 76 31 81 37 79 34 77 28 80 36 80 28
output:
0.0000000000 2 4 74 32 3 74 34
result:
ok correct
Test #27:
score: 0
Accepted
time: 0ms
memory: 9496kb
input:
3 3 74 19 75 15 70 17 74 10 75 17
output:
4.0000000000 2 0 75 19 3 75 15
result:
ok correct
Test #28:
score: 0
Accepted
time: 4ms
memory: 10448kb
input:
6 1 38 6 35 3 32 13 34 4 37 4 28 10 37 12 35 14
output:
3.0000000000 3 0 37 6 5 37 14 6 35 3
result:
ok correct
Test #29:
score: 0
Accepted
time: 5ms
memory: 12680kb
input:
9 2 91 54 90 52 86 61 90 59 90 63 97 54 93 60 96 56 85 63 89 58 95 59
output:
2.2360679775 1 0 90 52
result:
ok correct
Test #30:
score: 0
Accepted
time: 0ms
memory: 8440kb
input:
3 1 28 85 24 87 23 94 29 87 23 86
output:
2.0000000000 2 0 29 85 2 24 87
result:
ok correct
Test #31:
score: 0
Accepted
time: 5ms
memory: 19820kb
input:
18 1 56 70 54 77 56 72 52 71 54 69 53 67 52 72 55 73 51 71 59 74 49 77 58 80 59 72 60 77 50 70 56 71 61 71 63 79 60 76 54 69
output:
2.0000000000 2 14 56 69 18 54 77
result:
ok correct
Test #32:
score: 0
Accepted
time: 7ms
memory: 22620kb
input:
28 1 70 72 62 63 78 73 80 64 74 74 55 60 77 55 58 61 64 57 68 65 75 73 64 75 76 60 77 58 60 65 64 67 79 66 58 78 64 58 66 55 62 62 55 57 65 55 73 76 58 70 76 56 66 68 77 76 64 55 55 65
output:
3.0000000000 3 0 70 73 1 78 62 19 62 63
result:
ok correct
Test #33:
score: 0
Accepted
time: 13ms
memory: 30848kb
input:
40 1 72 56 63 68 70 58 70 63 55 55 52 76 83 52 84 86 49 66 63 76 57 65 82 77 50 78 82 76 78 53 74 58 66 65 80 71 57 77 54 71 77 86 67 88 71 71 80 74 65 70 48 66 80 86 82 69 72 78 72 73 74 65 84 49 68 75 47 52 75 82 83 55 52 76 49 88 47 48 70 61 45 60 44 49
output:
2.0000000000 2 27 63 78 8 63 68
result:
ok correct
Test #34:
score: 0
Accepted
time: 18ms
memory: 37700kb
input:
50 1 67 73 81 81 88 73 64 40 45 53 70 65 50 73 70 50 81 53 75 56 43 76 74 40 82 59 41 66 41 45 45 48 84 46 78 50 88 69 70 45 80 82 69 43 55 42 52 74 59 85 57 70 43 53 53 45 66 46 43 81 64 55 78 61 66 51 48 40 44 73 87 42 68 73 77 60 77 45 87 65 58 56 47 58 44 54 57 77 62 85 80 83 82 54 54 82 69 48 4...
output:
2.0000000000 2 33 44 53 7 81 81
result:
ok correct
Test #35:
score: 0
Accepted
time: 29ms
memory: 44432kb
input:
59 1 15 7 43 24 67 8 23 32 62 55 65 33 33 17 47 22 59 30 56 40 51 46 19 23 63 16 68 30 60 34 59 19 51 42 69 12 68 57 50 59 16 20 46 42 33 11 56 41 41 14 50 56 61 44 67 14 47 57 69 59 34 55 66 47 42 44 39 34 14 32 16 53 29 9 52 55 37 41 49 38 18 27 50 43 41 43 30 32 20 61 42 45 57 39 20 17 70 8 36 27...
output:
2.0000000000 2 50 43 7 52 43 24
result:
ok correct
Test #36:
score: 0
Accepted
time: 42ms
memory: 46212kb
input:
65 2 60 33 67 26 70 39 46 50 24 42 73 36 33 68 51 16 63 79 40 77 65 30 48 58 44 38 31 14 40 69 84 30 47 38 82 39 48 35 87 37 68 58 82 41 88 38 38 62 43 48 51 19 69 63 87 64 66 49 72 48 63 19 67 79 42 41 49 56 59 19 57 65 41 64 55 52 60 53 75 61 59 21 76 36 35 21 61 77 37 75 55 13 87 60 61 45 93 70 7...
output:
4.0000000000 2 37 60 37 51 67 26
result:
ok correct
Test #37:
score: 0
Accepted
time: 59ms
memory: 56700kb
input:
78 2 42 19 48 4 47 15 64 21 20 8 94 20 19 50 23 76 33 77 28 76 81 5 86 38 77 66 44 38 93 36 60 13 45 25 28 61 73 18 67 59 77 77 78 63 82 13 60 7 83 53 84 40 40 16 78 9 91 20 22 49 80 65 30 34 92 43 32 77 80 47 52 23 81 4 76 44 36 62 43 70 86 21 19 66 47 30 62 3 74 35 68 52 83 19 45 68 29 22 22 4 62 ...
output:
4.0000000000 2 45 83 4 48 48 4
result:
ok correct
Test #38:
score: 0
Accepted
time: 67ms
memory: 62828kb
input:
89 1 10 58 20 62 87 86 74 45 53 94 23 35 22 18 66 8 35 15 24 20 58 40 29 88 49 48 77 33 41 50 55 27 44 17 58 25 35 22 23 60 85 39 14 31 95 83 66 53 54 35 46 14 52 34 91 76 93 78 84 7 90 72 19 12 55 15 91 56 31 12 25 42 72 84 87 29 59 89 18 67 33 16 21 39 41 64 59 87 17 43 64 46 55 33 19 28 50 57 24 ...
output:
2.0000000000 2 77 41 58 52 20 62
result:
ok correct
Test #39:
score: 0
Accepted
time: 82ms
memory: 65928kb
input:
97 1 100 68 49 12 23 89 58 29 19 63 69 17 65 71 24 81 27 76 56 47 84 70 70 71 3 41 4 43 16 65 22 92 84 83 50 62 10 80 49 49 88 54 38 94 35 91 97 90 38 57 38 95 31 40 18 66 65 0 21 11 17 17 26 17 92 98 97 69 46 63 23 2 100 33 24 88 69 52 45 86 31 57 56 10 21 19 56 63 12 57 3 38 80 1 84 16 100 80 68 2...
output:
2.0000000000 2 62 49 75 18 49 12
result:
ok correct
Test #40:
score: -100
Runtime Error
input:
99 5 84 19 36 19 82 53 34 59 52 35 88 59 52 41 34 47 94 59 94 47 82 35 58 59 34 17 40 29 70 59 58 23 58 17 40 53 82 65 46 47 70 41 88 35 88 41 94 29 64 41 52 23 76 47 64 47 46 23 52 47 94 35 70 47 94 65 34 53 52 59 88 29 76 23 46 35 34 23 40 59 88 23 94 41 34 41 88 17 82 41 58 41 40 41 46 59 46 29 9...