QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#631988#5579. Bog of Eternal Stenchenze114514Compile Error//C++201.2kb2024-10-12 11:20:052024-10-12 11:20:06

Judging History

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

  • [2024-10-12 11:20:06]
  • 评测
  • [2024-10-12 11:20:05]
  • 提交

answer

void solve() {
    int n, m;
    cin >> n >> m;
    const ll INF = 1e18;
    vector<vector<pair<int, ll>>> adj(n + 1); // Adjacency list: (neighbor, stench change)

    for (int i = 0; i < m; ++i) {
        int u, v;
        ll s;
        cin >> u >> v >> s;
        adj[u].emplace_back(v, s);
    }

    vector<ll> stench(n + 1, INF);
    vector<bool> in_queue(n + 1, false);
    vector<int> cnt(n + 1, 0); // Count of relaxations for negative cycle detection (not needed here)
    stench[1] = 0;
    queue<int> q;
    q.push(1);
    in_queue[1] = true;

    while (!q.empty()) {
        int u = q.front();
        q.pop();
        in_queue[u] = false;

        for (auto &[v, s_uv] : adj[u]) {
            ll s_v_candidate = max(0LL, stench[u] + s_uv);
            if (s_v_candidate < stench[v]) {
                stench[v] = s_v_candidate;
                if (!in_queue[v]) {
                    q.push(v);
                    in_queue[v] = true;
                    // cnt[v]++;
                    // Optional negative cycle detection, but not necessary here
                }
            }
        }
    }

    cout << stench[n] << '\n';
}

Details

answer.code: In function ‘void solve()’:
answer.code:3:5: error: ‘cin’ was not declared in this scope
    3 |     cin >> n >> m;
      |     ^~~
answer.code:4:11: error: ‘ll’ does not name a type
    4 |     const ll INF = 1e18;
      |           ^~
answer.code:5:29: error: ‘ll’ was not declared in this scope
    5 |     vector<vector<pair<int, ll>>> adj(n + 1); // Adjacency list: (neighbor, stench change)
      |                             ^~
answer.code:5:19: error: ‘pair’ was not declared in this scope
    5 |     vector<vector<pair<int, ll>>> adj(n + 1); // Adjacency list: (neighbor, stench change)
      |                   ^~~~
answer.code:5:12: error: ‘vector’ was not declared in this scope
    5 |     vector<vector<pair<int, ll>>> adj(n + 1); // Adjacency list: (neighbor, stench change)
      |            ^~~~~~
answer.code:5:24: error: expected primary-expression before ‘int’
    5 |     vector<vector<pair<int, ll>>> adj(n + 1); // Adjacency list: (neighbor, stench change)
      |                        ^~~
answer.code:9:11: error: expected ‘;’ before ‘s’
    9 |         ll s;
      |           ^~
      |           ;
answer.code:10:26: error: ‘s’ was not declared in this scope
   10 |         cin >> u >> v >> s;
      |                          ^
answer.code:11:9: error: ‘adj’ was not declared in this scope
   11 |         adj[u].emplace_back(v, s);
      |         ^~~
answer.code:14:30: error: ‘INF’ was not declared in this scope
   14 |     vector<ll> stench(n + 1, INF);
      |                              ^~~
answer.code:14:16: error: ‘stench’ was not declared in this scope
   14 |     vector<ll> stench(n + 1, INF);
      |                ^~~~~~
answer.code:15:12: error: expected primary-expression before ‘bool’
   15 |     vector<bool> in_queue(n + 1, false);
      |            ^~~~
answer.code:16:12: error: expected primary-expression before ‘int’
   16 |     vector<int> cnt(n + 1, 0); // Count of relaxations for negative cycle detection (not needed here)
      |            ^~~
answer.code:18:5: error: ‘queue’ was not declared in this scope
   18 |     queue<int> q;
      |     ^~~~~
answer.code:18:11: error: expected primary-expression before ‘int’
   18 |     queue<int> q;
      |           ^~~
answer.code:19:5: error: ‘q’ was not declared in this scope
   19 |     q.push(1);
      |     ^
answer.code:20:5: error: ‘in_queue’ was not declared in this scope
   20 |     in_queue[1] = true;
      |     ^~~~~~~~
answer.code:27:32: error: ‘adj’ was not declared in this scope
   27 |         for (auto &[v, s_uv] : adj[u]) {
      |                                ^~~
answer.code:28:15: error: expected ‘;’ before ‘s_v_candidate’
   28 |             ll s_v_candidate = max(0LL, stench[u] + s_uv);
      |               ^~~~~~~~~~~~~~
      |               ;
answer.code:29:17: error: ‘s_v_candidate’ was not declared in this scope
   29 |             if (s_v_candidate < stench[v]) {
      |                 ^~~~~~~~~~~~~
answer.code:41:5: error: ‘cout’ was not declared in this scope
   41 |     cout << stench[n] << '\n';
      |     ^~~~