QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#611002#8038. Hammer to Fallwdbl857WA 3ms5692kbC++201.3kb2024-10-04 18:43:422024-10-04 18:43:43

Judging History

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

  • [2024-10-04 18:43:43]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:5692kb
  • [2024-10-04 18:43:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(0), cin.tie(0)
#define int long long
#define ll long long
#define int128 __int128
#define ull unsigned long long
#define endl "\n"
#define pi acos(-1)
#define pii pair<int, int>
const double eps = 1e-6;
const int N = 1e6 + 10, M = 1010, INF = 0x3f3f3f3f;
const int mod = 998244353;
int a[N];
vector<pii> s[N];
bool cmd(pii x, pii y)
{
    return x.second < y.second;
}
void solve()
{
    int n, m, q;
    cin >> n >> m >> q;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 0; i < m; i++)
    {
        int x, y, z;
        cin >> x >> y >> z;
        s[x].push_back({y, z});
        s[y].push_back({x, z});
    }
    for (int i = 1; i <= n; i++)
        sort(s[i].begin(), s[i].end(), cmd);
    int ans = 0;
    while (q--)
    {
        int x;
        cin >> x;
        if (a[x])
        {
            ans = (ans + a[x] * s[x][0].second % mod) % mod;
            a[s[x][0].first] += a[x];
            a[x] = 0;
        }
    }
    cout << ans << endl;
}
signed main()
{
    ios;
    int T = 1;
    // cin >> T;
    // cout << fixed << setprecision(8);
    for (int i = 1; i <= T; i++)
    {
        // cout << "Case " << i << ": ";
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 5664kb

input:

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

output:

12

result:

ok single line: '12'

Test #2:

score: 0
Accepted
time: 2ms
memory: 5664kb

input:

2 1 10
5000 5000
1 2 10000
1 2 2 1 2 2 1 1 1 2

output:

550000000

result:

ok single line: '550000000'

Test #3:

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

input:

10 10 10
5 14 99 14 18 4 58 39 48 60
2 4 4
6 9 56
10 8 34
7 5 96
1 3 26
3 7 92
6 8 4
5 1 72
7 6 39
7 2 93
8 8 9 10 2 2 5 9 2 3

output:

8810

result:

ok single line: '8810'

Test #4:

score: -100
Wrong Answer
time: 3ms
memory: 5596kb

input:

100 500 10000
89 61 65 85 89 2 32 97 13 70 29 86 68 74 84 64 54 39 26 84 56 95 73 11 70 26 60 40 84 58 68 33 65 71 55 2 11 71 49 85 14 59 38 11 60 8 81 78 27 32 52 49 35 94 62 72 64 50 12 45 77 74 92 67 92 38 81 39 12 29 60 70 53 33 25 60 7 83 4 85 47 32 13 58 85 86 44 68 44 1 81 62 97 7 66 62 5 16 ...

output:

2113687

result:

wrong answer 1st lines differ - expected: '609241', found: '2113687'