QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#869539#5947. Don't Break The Nileunderthetime0 1275ms37380kbC++143.0kb2025-01-25 10:57:332025-01-25 10:57:33

Judging History

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

  • [2025-01-25 10:57:33]
  • 评测
  • 测评结果:0
  • 用时:1275ms
  • 内存:37380kb
  • [2025-01-25 10:57:33]
  • 提交

answer

#include <bits/stdc++.h>
bool MemoryST; using namespace std;
#define ll long long
#define mk make_pair
#define open(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define abs(x) (((x) > (0)) ? (x) : (-(x)))
#define lowbit(x) ((x) & (-(x)))
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
#define BCNT __builtin_popcount
#define cost_time (1e3 * clock() / CLOCKS_PER_SEC)
#define cost_space (abs(&MemoryST - &MemoryED) / 1024.0 / 1024.0) << "MB"
const ll inf = 1e18; 
mt19937 rnd(random_device{}());
const int maxn = 1005;
int T, n, m, k, st, ed;
struct Matrix {
    int x0, y0, x1, y1;
} a[maxn]; namespace Graph {
    struct Edge { int to, nxt, val; } e[maxn * maxn << 1];
    int head[maxn], ecnt = 0;
    void addEdge(int u, int v, int w) { e[++ ecnt] = Edge { v, head[u], w }, head[u] = ecnt; }
} using namespace Graph;
priority_queue<pair<ll, int> >q; ll dis[maxn]; bool vis[maxn];
void work() {
    for (int i = st; i <= ed; i ++) dis[i] = inf, vis[i] = 0;
    dis[st] = 0, q.push(mk(0, st));
    while (!q.empty()) {
        int u = q.top().second; q.pop();
        if (vis[u]) continue; vis[u] = 1;
        // cout << u << ' ' << dis[u] << '\n';
        for (int i = head[u]; i; i = e[i].nxt) {
            int v = e[i].to, w = e[i].val;
            if (dis[v] > dis[u] + w) {
                dis[v] = dis[u] + w;
                if (!vis[v]) q.push(mk(-dis[v], v));
            }
        }
    }
}
bool MemoryED; int main() {
    auto chkmin = [&](int &a, int b) -> void { a = min(a, b); };
    auto dis = [&](int x0, int y0, int x1, int y1) -> int { return max(abs(x0 - x1) - 1, abs(y0 - y1) - 1); };
    scanf("%d", &T); for (int NOW_TEST = 1; NOW_TEST <= T; NOW_TEST ++) {
        scanf("%d %d %d", &m, &n, &k), st = 0, ed = k + 1, ecnt = 0;
        memset(head, 0, sizeof(head));
        for (int i = 1; i <= k; i ++) 
            scanf("%d %d %d %d", &a[i].x0, &a[i].y0, &a[i].x1, &a[i].y1);
        addEdge(st, ed, m);
        for (int i = 1; i <= k; i ++) {
            auto [x0, y0, x1, y1] = a[i];
            addEdge(st, i, x0), addEdge(i, ed, m - x1 - 1);
            for (int j = 1; j <= k; j ++) if (i != j) {
                auto [x0_, y0_, x1_, y1_] = a[j]; int w;
                if ((y0_ <= y0 && y0 <= y1_) || (y0_ <= y1 && y1 <= y1_))
                    w = min(abs(x0 - x1_), abs(x1 - x0_)) - 1;
                else if ((x0_ <= x0 && x0 <= x1_) || (x0_ <= x1 && x1 <= x1_))
                    w = min(abs(y0 - y1_), abs(y1 - y0_)) - 1;
                else w = min(min(dis(x0, y0, x1_, y1_), dis(x0, y1, x1_, y0)), min(dis(x1, y1, x0_, y0_), dis(x1, y0, x0_, y1_)));
                // cout << i << ' ' << j << ':' << w << '\n';
                addEdge(i, j, w), addEdge(j, i, w);
            }
        } work(), printf("Case #%d: %lld\n", NOW_TEST, ::dis[ed]);
    }
    return 0;
}
/*
1
100 500 9
8 17 39 311
95 254 96 388
15 340 33 396
55 202 91 268
41 88 47 108
60 375 82 425
59 54 79 113
50 65 54 490
74 288 91 305
*/

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3840kb

input:

100
16 419 0
100 500 10
35 322 66 396
68 250 82 420
5 121 42 318
20 375 26 479
94 192 97 233
55 160 63 186
60 145 70 147
50 34 88 61
22 46 32 98
45 158 54 272
100 500 10
8 17 39 311
95 254 96 388
15 340 33 396
55 202 91 268
41 88 47 108
60 375 82 425
59 54 79 113
50 65 54 490
74 288 91 305
7 419 16 ...

output:

Case #1: 16
Case #2: 26
Case #3: 17
Case #4: 37
Case #5: 1
Case #6: 13
Case #7: 34
Case #8: 0
Case #9: 32
Case #10: 12
Case #11: 8
Case #12: 0
Case #13: 0
Case #14: 0
Case #15: 19
Case #16: 0
Case #17: 0
Case #18: 0
Case #19: 0
Case #20: 26
Case #21: 0
Case #22: 35
Case #23: 31
Case #24: 0
Case #25:...

result:

wrong answer 9th lines differ - expected: 'Case #9: 37', found: 'Case #9: 32'

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 1275ms
memory: 37380kb

input:

100
84 50179773 32
20 32106308 34 47087131
4 6143627 58 7485509
2 33630407 9 37620847
17 13949314 77 19091045
14 19581218 32 24801601
36 30619147 57 41800856
72 337518 76 12161651
65 48679970 81 48726892
6 1649581 67 4149005
81 23550973 81 35817181
7 28241840 52 28815431
7 8797285 61 11989656
71 204...

output:

Case #1: 14
Case #2: 165
Case #3: 175
Case #4: 99
Case #5: 2
Case #6: 8
Case #7: 93
Case #8: 86
Case #9: 14
Case #10: 0
Case #11: 17
Case #12: 15
Case #13: 27
Case #14: 0
Case #15: 0
Case #16: 30
Case #17: 0
Case #18: 0
Case #19: 0
Case #20: 2
Case #21: 72
Case #22: 117
Case #23: 111
Case #24: 64
Ca...

result:

wrong answer 13th lines differ - expected: 'Case #13: 35', found: 'Case #13: 27'