QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#170038#7184. Transport Plusesucup-team1264#WA 214ms4044kbC++202.4kb2023-09-09 14:32:192023-09-09 14:38:08

Judging History

你现在查看的是最新测评结果

  • [2023-09-09 14:38:08]
  • 管理员手动重测该提交记录
  • 测评结果:WA
  • 用时:214ms
  • 内存:4044kb
  • [2023-09-09 14:32:19]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;

const int N = 101 * 101;

#define double float

void solve() {
    int n, t;
    cin >> n >> t;
    int xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    vector<vector<int>> pnt(101, vector<int>(101, 0));
    vector<vector<double>> ans(101, vector<double>(101, 1e5));
    vector<vector<int>> chosen(101, vector<int>(101, 0));
    for (int i = 1; i <= n; i++) {
        int x, y;
        cin >> x >> y;
        pnt[x][y] = i;
    }
    vector fa(101, vector<tuple<int, int, int>>(101, {-1, -1, -1}));
    ans[xs][ys] = 0;
    for (int _ = 0; _ < N; _++) {
        int mn = 1e5;
        pair<int, int> mnp = {-1, -1};
        for (int i = 0; i <= 100; i++) {
            for (int j = 0; j <= 100; j++) {
                if (!chosen[i][j] && ans[i][j] < mn) {
                    mn = ans[i][j];
                    mnp = {i, j};
                }
            }
        }
        auto [x, y] = mnp;
        if (x == xt && y == yt) break;
        chosen[x][y] = 1;
        for (int i = 0; i <= 100; i++) {
            for (int j = 0; j <= 100; j++) {
                if (chosen[i][j]) continue;
                if (ans[x][y] + sqrt((i - x) * (i - x) + (j - y) * (j - y)) <
                    ans[i][j]) {
                    ans[i][j] =
                        ans[x][y] + sqrt((i - x) * (i - x) + (j - y) * (j - y));
                    fa[i][j] = {0, x, y};
                }
                if (ans[x][y] + t < ans[i][j]) {
                    if (pnt[i][y]) {
                        ans[i][j] = ans[x][y] + t;
                        fa[i][j] = {pnt[i][y], x, y};
                    } else if (pnt[x][j]) {
                        ans[i][j] = ans[x][y] + t;
                        fa[i][j] = {pnt[x][j], x, y};
                    }
                }
            }
        }
    }
    cout << fixed << setprecision(10) << ans[xt][yt] << "\n";
    vector<tuple<int, int, int>> res;
    for (int i = xt, j = yt; i != xs || j != ys;) {
        auto [tp, x, y] = fa[i][j];
        res.emplace_back(tp, i, j);
        i = x, j = y;
    }
    ranges::reverse(res);
    cout << res.size() << "\n";
    for (auto [tp, x, y] : res) {
        cout << tp << " " << x << " " << y << "\n";
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 6ms
memory: 3900kb

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: 8ms
memory: 3828kb

input:

2 1
1 1
6 1
1 3
6 3

output:

2.0000000000
2
1 0 3
2 6 1

result:

ok correct

Test #3:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

0 0
1 1
1 1

output:

0.0000000000
0

result:

ok correct

Test #4:

score: 0
Accepted
time: 209ms
memory: 4044kb

input:

0 0
100 100
0 0

output:

141.4212951660
37
0 94 94
0 93 93
0 92 92
0 91 91
0 90 90
0 89 89
0 87 87
0 85 85
0 83 83
0 81 81
0 79 79
0 75 75
0 71 71
0 67 67
0 63 63
0 59 59
0 55 55
0 52 52
0 49 49
0 46 46
0 43 43
0 40 40
0 37 37
0 34 34
0 31 31
0 28 28
0 25 25
0 22 22
0 19 19
0 16 16
0 13 13
0 10 10
0 4 4
0 3 3
0 2 2
0 1 1
0 ...

result:

ok correct

Test #5:

score: 0
Accepted
time: 209ms
memory: 4028kb

input:

1 0
100 100
0 0
100 100

output:

100.0000000000
2
1 0 100
0 0 0

result:

ok correct

Test #6:

score: 0
Accepted
time: 0ms
memory: 3992kb

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: 1ms
memory: 3988kb

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: 185ms
memory: 3848kb

input:

1 100
50 50
0 0
50 50

output:

70.7106628418
20
0 44 44
0 43 43
0 42 42
0 41 41
0 40 40
0 39 39
0 37 37
0 35 35
0 33 33
0 31 31
0 29 29
0 25 25
0 21 21
0 17 17
0 13 13
0 9 9
0 5 5
0 2 2
0 1 1
0 0 0

result:

ok correct

Test #9:

score: 0
Accepted
time: 191ms
memory: 3844kb

input:

1 100
50 50
0 0
0 50

output:

70.7106628418
20
0 44 44
0 43 43
0 42 42
0 41 41
0 40 40
0 39 39
0 37 37
0 35 35
0 33 33
0 31 31
0 29 29
0 25 25
0 21 21
0 17 17
0 13 13
0 9 9
0 5 5
0 2 2
0 1 1
0 0 0

result:

ok correct

Test #10:

score: 0
Accepted
time: 197ms
memory: 3936kb

input:

1 100
50 50
0 0
51 51

output:

70.7106628418
20
0 44 44
0 43 43
0 42 42
0 41 41
0 40 40
0 39 39
0 37 37
0 35 35
0 33 33
0 31 31
0 29 29
0 25 25
0 21 21
0 17 17
0 13 13
0 9 9
0 5 5
0 2 2
0 1 1
0 0 0

result:

ok correct

Test #11:

score: 0
Accepted
time: 186ms
memory: 3972kb

input:

1 100
50 50
0 0
2 53

output:

70.7106628418
20
0 44 44
0 43 43
0 42 42
0 41 41
0 40 40
0 39 39
0 37 37
0 35 35
0 33 33
0 31 31
0 29 29
0 25 25
0 21 21
0 17 17
0 13 13
0 9 9
0 5 5
0 2 2
0 1 1
0 0 0

result:

ok correct

Test #12:

score: 0
Accepted
time: 188ms
memory: 4028kb

input:

1 100
0 0
100 100
50 50

output:

141.4212951660
37
0 6 6
0 7 7
0 8 8
0 9 9
0 10 10
0 11 11
0 13 13
0 15 15
0 17 17
0 19 19
0 21 21
0 25 25
0 29 29
0 33 33
0 37 37
0 41 41
0 45 45
0 48 48
0 51 51
0 54 54
0 57 57
0 60 60
0 63 63
0 66 66
0 69 69
0 72 72
0 75 75
0 78 78
0 81 81
0 84 84
0 87 87
0 90 90
0 96 96
0 97 97
0 98 98
0 99 99
0 ...

result:

ok correct

Test #13:

score: 0
Accepted
time: 195ms
memory: 4040kb

input:

1 33
0 0
100 100
50 50

output:

133.0000000000
3
0 0 50
1 50 100
0 100 100

result:

ok correct

Test #14:

score: 0
Accepted
time: 214ms
memory: 3892kb

input:

1 12
100 0
11 90
0 100

output:

122.0000000000
3
0 0 0
1 11 100
0 11 90

result:

ok correct

Test #15:

score: 0
Accepted
time: 203ms
memory: 3976kb

input:

1 12
100 0
10 89
0 100

output:

122.0000000000
3
0 100 100
1 0 89
0 10 89

result:

ok correct

Test #16:

score: 0
Accepted
time: 10ms
memory: 4044kb

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: 3900kb

input:

2 2
2 1
5 1
1 3
6 3

output:

3.0000000000
1
0 5 1

result:

ok correct

Test #18:

score: -100
Wrong Answer
time: 6ms
memory: 3896kb

input:

1 2
1 1
5 3
7 2

output:

4.4721360207
2
0 3 2
0 5 3

result:

wrong answer read 4.472136 but expected 4.000000, error = 0.472136