QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#784112#8874. Labelled PathsalexhamidiWA 0ms3552kbC++201.6kb2024-11-26 13:27:252024-11-26 13:27:26

Judging History

This is the latest submission verdict.

  • [2024-11-26 13:27:26]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3552kb
  • [2024-11-26 13:27:25]
  • Submitted

answer

#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>

using namespace std;

const int INF = numeric_limits<int>::max();

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m, d, s;
    cin >> n >> m >> d >> s;

    string A;
    cin >> A;

    vector<vector<pair<string, int>>> adj(n+1);
    for (int i = 0; i < m; i++) {
        int u, v, p, l;
        cin >> u >> v >> p >> l;
        adj[u].push_back({A.substr(p-1, l), v});
    }

    for (int target = 1; target <= n; target++) {
        vector<int> dist(n+1, INF);
        vector<int> prev(n+1, -1);
        dist[s] = 0;

        queue<pair<int, string>> q;
        q.push({s, ""});

        while (!q.empty()) {
            auto [node, currentPath] = q.front();
            q.pop();

            if (node == target) break;

            for (auto [edgeLabel, nextNode] : adj[node]) {
                if (dist[nextNode] > dist[node] + 1) {
                    dist[nextNode] = dist[node] + 1;
                    prev[nextNode] = node;
                    q.push({nextNode, currentPath + edgeLabel});
                }
            }
        }

        if (dist[target] == INF) {
            cout << 0 << "\n";
        } else {
            vector<int> path;
            for (int at = target; at != -1; at = prev[at]) {
                path.push_back(at);
            }
            reverse(path.begin(), path.end());

            cout << path.size() << " ";
            for (int node : path) cout << node << " ";
            cout << "\n";
        }
    }

    return 0;
}

詳細信息

Test #1:

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

input:

11 30 105 9
fufuffuffuuuuuufuffuffuufffuufufuuuuuuuuuufffufufffuuufuffufufuuffffuufffuffffuffffufuuuufuufuuffuuuufffu
1 6 51 1
5 2 6 1
9 6 57 3
11 8 86 4
10 8 95 0
6 2 17 0
6 3 78 0
7 3 50 0
11 4 98 3
10 3 77 3
5 4 18 4
7 4 81 1
9 7 82 0
1 3 79 2
7 5 13 4
1 10 86 2
10 4 10 0
9 3 4 0
6 11 10 4
6 4 82...

output:

2 9 1 
3 9 6 2 
2 9 3 
3 9 6 4 
3 9 7 5 
2 9 6 
2 9 7 
3 9 3 8 
1 9 
3 9 1 10 
3 9 6 11 

result:

wrong answer wrong solution for vertex 2