QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#350348#6523. Escape PlanreginoxWA 354ms34388kbC++171.5kb2024-03-10 17:36:222024-03-10 17:36:22

Judging History

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

  • [2024-03-10 17:36:22]
  • 评测
  • 测评结果:WA
  • 用时:354ms
  • 内存:34388kb
  • [2024-03-10 17:36:22]
  • 提交

answer

/*
Dijkstra's algorithm to find single source shortest path from vertex 1
https://cses.fi/problemset/task/1671
*/
#include<bits/stdc++.h>
#define task "test"
#define pint pair<int,int>
using namespace std;
const int maxn = 1e5+3;
int n, m, dd[maxn], last[maxn], e[maxn], d[maxn], k;
vector<pint> g[maxn];
vector<int> path;
priority_queue<pint, vector<pint>, greater<pint>> pq;

void dijkstra(int s){
    pq.push({0, s});
    while(!pq.empty()){
        pint p = pq.top();
        int u = p.second;
//        cerr << u << "\n";
        pq.pop();
        --dd[u];
        if(dd[u] == -1){
            d[u] = p.first;
            for(auto [v, w]:g[u]){
                pq.push({p.first+w, v});
            }
        }
    }
}

void solve(){
    cin >> n >> m >> k;
    fill_n(e+1, n, 0);
    d[1] = -1;
    for(int i = 0; i <= n; i++)  g[i].clear();
    for(int i = 1; i <= k; i++){
        int x;
        cin >> x;
        e[x] = 1;
        g[0].emplace_back(x, 0);
    }
    for(int i = 1; i <= n; i++){
        cin >> dd[i];
        if(e[i] == 1) dd[i] = 0;
    }
    for(int i = 1; i <= m; i++){
        int x, y, w;
        cin >> x >> y >> w;
        g[x].emplace_back(y, w);
        g[y].emplace_back(x, w);
    }
    dijkstra(0);
    cout << d[1] << "\n";
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 6656kb

input:

2
3 4 1
3
1 1 1
1 2 1
1 2 2
2 3 1
2 3 2
3 2 2
2 3
2 0 0
1 2 1
1 3 1

output:

4
-1

result:

ok 2 number(s): "4 -1"

Test #2:

score: -100
Wrong Answer
time: 354ms
memory: 34388kb

input:

100
100 1808 2
94 47
3 3 0 2 4 3 3 4 0 0 2 2 2 3 2 4 0 2 3 4 4 2 0 3 4 3 1 0 2 1 2 2 0 3 4 4 4 1 2 2 3 1 0 0 3 1 4 2 1 3 3 4 3 0 4 1 0 3 2 1 4 4 1 3 2 3 3 3 3 1 0 3 0 4 3 1 0 4 0 4 4 1 2 0 0 4 1 3 3 3 0 2 2 1 1 2 3 4 1 2
72 29 1138
59 78 2398
95 5 1610
32 46 4176
36 99 8143
100 69 413
61 58 1595
9 9...

output:

5109
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

result:

wrong answer 2nd numbers differ - expected: '1021', found: '-1'