QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#784086#8874. Labelled PathsalexhamidiRE 0ms3600kbC++201.3kb2024-11-26 13:12:152024-11-26 13:12:15

Judging History

This is the latest submission verdict.

  • [2024-11-26 13:12:15]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 3600kb
  • [2024-11-26 13:12:15]
  • Submitted

answer

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n, m, d, s;
    cin >> n >> m >> d >> s;

    string A;  //all edge labels are substrings of A
    cin >> A;

    vector<pair<string, int>> adj[n+1]; //target, substring
    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 i = 1; i <= n; i++) {

        vector<pair<string, vector<int>>> wrk;
        vector<pair<string, vector<int>>> cmp; //they are getting cumulative,

        wrk.push_back({"",{s}});

        while (!wrk.empty()) {
            vector<pair<string, vector<int>>> cwrk;
            for (auto [s, vec] : wrk) {
                int ln = vec.back();
                if (ln == i) {
                    cmp.push_back({s, vec});
                } else for (auto [newS, v] : adj[ln]) {
                    vector<int> tmp = vec;
                    tmp.push_back(v);
                    cwrk.push_back({s+newS, tmp});
                }
            }
            wrk = cwrk;
        }
        auto [_, bestPath] = *min_element(cmp.begin(), cmp.end());
        cout << bestPath.size() << " ";
        for (auto node : bestPath) cout << node << " ";
        cout << "\n";
    }
    return 0;
}


詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

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 1 2 
2 9 3 
3 9 7 4 
3 9 1 5 
3 9 1 6 
2 9 7 
6 9 1 5 6 3 8 
1 9 
3 9 1 10 
3 9 7 11 

result:

ok good!

Test #2:

score: -100
Runtime Error

input:

12 35 74 2
iggigggggiigiggggiigggigigiiggiiigiigiggiggiiggiiiigigggggigggggigggggggii
6 4 1 1
8 10 9 4
11 7 1 0
6 10 11 0
12 10 30 4
3 1 11 1
1 9 35 2
2 1 24 4
7 10 15 0
3 5 31 0
3 11 11 1
1 4 67 2
2 5 19 4
9 4 32 0
2 6 48 1
8 9 49 0
7 9 39 1
8 12 61 4
12 7 54 0
12 4 22 4
6 9 73 0
9 10 13 3
2 8 71 4...

output:


result: