QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#274429#7883. Takeout DeliveringzhensuanWA 103ms22992kbC++201.8kb2023-12-03 15:28:322023-12-03 15:28:33

Judging History

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

  • [2023-12-03 15:28:33]
  • 评测
  • 测评结果:WA
  • 用时:103ms
  • 内存:22992kb
  • [2023-12-03 15:28:32]
  • 提交

answer

#include<bits/stdc++.h>
//#define int long long
#define endl '\n'
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 3e5 + 5;
vector<pair<int, int>>e[maxn];
bool vis[maxn], vis1[maxn];
int dis[maxn];
int mx[maxn];
struct node1 {
    int id, mx;
    friend bool operator <(node1 a, node1 b) {
        return a.mx > b.mx;
    }
};
void bfs() {
    priority_queue<node1>q;
    mx[1] = 0;
    q.push({ 1,0 });
    while (!q.empty()) {
        auto [u, _] = q.top();
        q.pop();
        if (vis1[u])continue;
        vis1[u] = true;
        for (auto [v, w] : e[u]) {
            if (mx[v] > max(mx[u], w)) {
                mx[v] = max(mx[u], w);
                q.push({ v,mx[v] });
            }
        }
    }
}
struct node {
    int id;
    int x, y;
    friend bool operator <(node a, node b) {
        return a.x + a.y > b.x + b.y;
    }
};
void dij() {
    priority_queue<node>q;
    dis[1] = 0;
    q.push({ 1,0,0 });
    while (!q.empty()) {
        auto [u, x, y] = q.top();
        q.pop();
        if (vis[u])continue;
        vis[u] = true;
        for (auto [v, w] : e[u]) {
            if (w >= y) {
                if (dis[v] > w + mx[u]) {
                    dis[v] = w + mx[u];
                    q.push({ v, max(w, mx[u]), min(w, mx[u]) });
                }
            }
        }
    }
}
void solve() {
    int n, m;
    cin >> n >> m;
    int res = 2e9 + 7;
    memset(dis, 0x3f, sizeof dis);
    memset(mx, 0x3f, sizeof mx);
    for (int i = 1;i <= m;i++) {
        int u, v, w;
        cin >> u >> v >> w;
        e[u].push_back({ v,w });
        e[v].push_back({ u,w });
    }
    bfs();
    dij();
    cout << dis[n] << endl;
}
signed main() {
    int t = 1;
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    while (t--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 13620kb

input:

4 6
1 2 2
1 3 4
1 4 7
2 3 1
2 4 3
3 4 9

output:

5

result:

ok 1 number(s): "5"

Test #2:

score: -100
Wrong Answer
time: 103ms
memory: 22992kb

input:

300000 299999
80516 80517 597830404
110190 110191 82173886
218008 218009 954561262
250110 250111 942489774
66540 66541 156425292
34947 34948 239499776
273789 273790 453201232
84428 84429 439418398
98599 98600 326095035
55636 55637 355015760
158611 158612 684292473
43331 43332 43265001
171621 171622 ...

output:

1061109567

result:

wrong answer 1st numbers differ - expected: '1999991697', found: '1061109567'