QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#420877#8038. Hammer to Fallfishy15WA 0ms3552kbC++141.6kb2024-05-25 02:47:022024-05-25 02:47:02

Judging History

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

  • [2024-05-25 02:47:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-05-25 02:47:02]
  • 提交

answer

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

#define rep(i, a, b) for(int i = a; i < (b); i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

constexpr ll INF = 2e18;

ll bpow(ll a, ll b, ll m) {
    ll ans = 1;
    while (b) {
        if (b & 1) ans = ans * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return ans;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int n, m, q;
    cin >> n >> m >> q;
    vector<ll> dist(n);
    vector<ll> guys(n);
    for(int i = 0; i < n; i++) {
        cin >> guys[i];
    }
    vector<vector<pair<int, ll>>> con(n);
    for(int i = 0; i < m; i++) {
        int a, b;
        ll w;
        cin >> a >> b >> w;
        a--; b--;
        con[a].push_back({b, w});
        con[b].push_back({a, w});
    }
    vector<int> queries(q);
    map<int, int> first;
    for(int i = 0; i < q; i++) {
        cin >> queries[i];
        queries[i]--;
    }
    for(int i = 0; i < q; i++) {
        if(first.count(queries[i]) == 0)
            first[queries[i]] = i;
    }
    ll ans = 0;
    for(int time = q-1; time >= 0; time--) {
        int Q = queries[time];
        ll best = INF;
        for(auto next : con[Q]) {
            int nextId = next.first;
            ll cost = next.second;
            best = min(best, dist[nextId]+cost);
        }
        dist[Q] = best;
        if(time == first[Q])
            ans += dist[Q]*guys[Q];
    }
    for(ll d : dist)
        cout << d << " ";
    cout << endl;
    cout << ans << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 2 2
1 1 1
2 3 10
1 2 1
3 2

output:

0 1 11 
12

result:

wrong answer 1st lines differ - expected: '12', found: '0 1 11 '