提出 #69612112


ソースコード 拡げる

#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
const int N = 3e5 + 10;
int n, m, na, nb, d, a[N], b[N], mark[N], ans[N];
bool vis[N];
vector<pii> g[N];
bool cmp(pii x, pii y) {
    return x.second < y.second;
}
priority_queue<pii, vector<pii>, greater<pii>> q;
vector<pii> vec;
void dfs(int u, int dist, int t) {
    vis[u] = true;
    if (ans[u] == -1)
        ans[u] = t;
    for (; mark[u] < g[u].size(); mark[u]++) {
        auto [v, w] = g[u][mark[u]];
        if (vis[v])
            continue;
        if (dist >= w)
            dfs(v, dist - w, t);
        else
            break;
    }
    if (!g[u].empty() and mark[u] < g[u].size())
        vec.push_back({g[u][mark[u]].second, u});
}
signed main() {
    IOS;
    cin >> n >> m;
    for (int i = 1, u, v, w; i <= m; i++) {
        cin >> u >> v >> w;
        g[u].push_back({v, w});
        g[v].push_back({u, w});
    }
    for (int i = 1; i <= n; i++)
        sort(g[i].begin(), g[i].end(), cmp);
    memset(ans, -1, sizeof ans);
    cin >> na;
    for (int i = 1; i <= na; i++) {
        cin >> a[i];
        ans[a[i]] = 0;
        if (!g[a[i]].empty())
            q.push({g[a[i]][0].second, a[i]});
    }
    cin >> d;
    for (int i = 1, x; i <= d; i++) {
        cin >> x;
        vec.clear();
        while (!q.empty()) {
            auto [f, u] = q.top();
            if (f > x)
                break;
            q.pop();
            dfs(u, x, i);
        }
        for (pii x : vec)
            q.push(x);
    }
    for (int i = 1; i <= n; i++)
        cout << ans[i] << "\n";
    return 0;
}

提出情報

提出日時
問題 F - Virus 2
ユーザ Garbage_fish
言語 C++ 20 (gcc 12.2)
得点 0
コード長 1781 Byte
結果 WA
実行時間 282 ms
メモリ 46840 KiB

コンパイルエラー

Main.cpp: In function ‘void dfs(long long int, long long int, long long int)’:
Main.cpp:20:20: warning: comparison of integer expressions of different signedness: ‘long long int’ and ‘std::vector<std::pair<long long int, long long int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   20 |     for (; mark[u] < g[u].size(); mark[u]++) {
      |            ~~~~~~~~^~~~~~~~~~~~~
Main.cpp:29:35: warning: comparison of integer expressions of different signedness: ‘long long int’ and ‘std::vector<std::pair<long long int, long long int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   29 |     if (!g[u].empty() and mark[u] < g[u].size())
      |                           ~~~~~~~~^~~~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 550
結果
AC × 3
AC × 26
WA × 18
セット名 テストケース
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 5 ms 5872 KiB
example_01.txt AC 4 ms 5816 KiB
example_02.txt AC 3 ms 5888 KiB
hand_00.txt AC 171 ms 28196 KiB
hand_01.txt AC 244 ms 31204 KiB
hand_02.txt AC 142 ms 26424 KiB
hand_03.txt AC 140 ms 26496 KiB
hand_04.txt AC 31 ms 5848 KiB
hand_05.txt AC 231 ms 37384 KiB
hand_06.txt AC 265 ms 46840 KiB
hand_07.txt AC 107 ms 27064 KiB
hand_08.txt AC 20 ms 5816 KiB
hand_09.txt AC 154 ms 22960 KiB
hand_10.txt AC 180 ms 31232 KiB
random_00.txt WA 268 ms 32264 KiB
random_01.txt WA 282 ms 32284 KiB
random_02.txt WA 279 ms 32572 KiB
random_03.txt WA 259 ms 32468 KiB
random_04.txt WA 251 ms 32436 KiB
random_05.txt WA 254 ms 32524 KiB
random_06.txt AC 168 ms 29828 KiB
random_07.txt AC 162 ms 30360 KiB
random_08.txt WA 205 ms 32268 KiB
random_09.txt WA 141 ms 23040 KiB
random_10.txt WA 141 ms 23336 KiB
random_11.txt WA 140 ms 23384 KiB
random_12.txt AC 119 ms 23100 KiB
random_13.txt WA 119 ms 23176 KiB
random_14.txt WA 112 ms 23464 KiB
random_15.txt WA 131 ms 23508 KiB
random_16.txt WA 129 ms 22876 KiB
random_17.txt WA 134 ms 23508 KiB
random_18.txt WA 90 ms 22136 KiB
random_19.txt AC 91 ms 22756 KiB
random_20.txt AC 71 ms 14508 KiB
random_21.txt AC 52 ms 19084 KiB
random_22.txt AC 48 ms 14160 KiB
random_23.txt AC 55 ms 17020 KiB
random_24.txt WA 76 ms 21380 KiB
random_25.txt AC 66 ms 17064 KiB
random_26.txt AC 58 ms 14272 KiB
random_27.txt AC 168 ms 27660 KiB
random_28.txt AC 149 ms 28640 KiB
random_29.txt WA 242 ms 31148 KiB