제출 #927676

#제출 시각아이디문제언어결과실행 시간메모리
927676LonlyRRobot (JOI21_ho_t4)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #define int long long #define ii pair<int,int> #define ff first #define ss second using namespace std; const int maxn = 2e5 + 5; int n, m; int dp[maxn]; vector<array<int, 3>> adj[maxn]; map<int,int> col[maxn]; map<int,ii> dpc[maxn]; map<int,vector<ii>> adjc[maxn]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("test.inp", "r", stdin); // freopen("test.out", "w", stdout); cin >> n >> m; for (int i = 1, u, v, w, t; i <= m; i++) { cin >> u >> v >> w >> t; adj[u].push_back({v, w, t}); adj[v].push_back({u, w, t}); adjc[u][w].emplace_back(v, t); adjc[v][w].emplace_back(u, t); col[u][w] += t; col[v][w] += t; } for (int i = 1; i <= n; i++) for (auto p : adj[i]) { int &u = col[i][p[1]]; if (u == 0) continue; if (u == -1) u = p[2]; else u += p[2]; } #define iii tuple<int,int,int> priority_queue<iii, vector<iii>, greater<iii>> pq; memset(dp, 0x3f, sizeof dp); int oo = dp[0]; dp[1] = 0; pq.emplace(0, 1, 0); while (pq.size()) { int u, v, w; tie(v, u, w) = pq.top(); pq.pop(); if (w == 0) { if (v != dp[u]) continue; for (auto p : adj[u]) { int color = p[1], cost = p[2], nxt = p[0]; int val = v + cost, f = 0; if (dp[nxt] > val) dp[nxt] = val, f = 1; if (!dpc[nxt].count(color) || dpc[nxt][color].ff > val - cost) dpc[nxt][color] = {val - cost, u}, pq.emplace(val - cost, nxt, color); val = v + col[u][color] - cost; if (dp[nxt] > val) dp[nxt] = val, f = 1; if (f) pq.emplace(dp[nxt], nxt, 0); } } } else for (auto p : adjc[u][w]) { int nxt = p.ff, cost = p.ss, color = w; if (nxt != dpc[u][color].ss) { int val = dpc[u][color].ff + col[u][color] - cost; if (dp[nxt] > val) dp[nxt] = val, pq.emplace(dp[nxt], nxt, 0); if (!dpc[nxt].count(color) || dpc[nxt][color].ff > val - cost) dpc[nxt][color] = {val - cost, u}, pq.emplace(val - cost, nxt, color); } } } cout << (dp[n] == oo ? -1 : dp[n]); }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:73:9: error: 'else' without a previous 'if'
   73 |         else for (auto p : adjc[u][w])
      |         ^~~~
Main.cpp:73:33: error: 'u' was not declared in this scope
   73 |         else for (auto p : adjc[u][w])
      |                                 ^
Main.cpp:73:36: error: 'w' was not declared in this scope
   73 |         else for (auto p : adjc[u][w])
      |                                    ^
Main.cpp:76:31: error: 'color' was not declared in this scope; did you mean 'col'?
   76 |             if (nxt != dpc[u][color].ss)
      |                               ^~~~~
      |                               col
Main.cpp:78:62: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   78 |                 int val = dpc[u][color].ff + col[u][color] - cost;
      |                                                              ^~~~
      |                                                              cosl
Main.cpp:44:9: warning: unused variable 'oo' [-Wunused-variable]
   44 |     int oo = dp[0];
      |         ^~
Main.cpp: At global scope:
Main.cpp:88:5: error: 'cout' does not name a type
   88 |     cout << (dp[n] == oo ? -1 : dp[n]);
      |     ^~~~
Main.cpp:89:1: error: expected declaration before '}' token
   89 | }
      | ^