제출 #956243

#제출 시각아이디문제언어결과실행 시간메모리
956243samvar_0907Olympic Bus (JOI20_ho_t4)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 201, M = 40001; int n, m; multiset<pair<int, int>> adj[N]; int c[M], d[M]; pair<int, int> edges[M]; vector<int> dijkstra(int source){ vector<int> dist(n + 1, 1e15); priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; pq.push({0, source}); dist[source] = 0; while (!pq.empty()) { int u = pq.top().second; int d = pq.top().first; pq.pop(); for (auto &n : adj[u]){ if (dist[n.first] > d + c[n.second]){ dist[n.first] = d + c[n.second]; pq.push({dist[n.first], n.first}); } } } return dist; } signed main(){ cin >> n >> m; for (int i = 1; i <= n; ++i) { adj[i].clear(); } vector<vector<ll>> dist(n + 1, vector<ll>(n + 1, 1e15)); for (ll i = 1; i <= n; ++i) { dist[i][i] = 0; } for (int i = 0; i < m; ++i){ int u, v; cin >> u >> v >> c[i] >> d[i]; adj[u].insert({v, i}); edges[i] = {u, v}; dist[u][v] = min(dist[u][v], c[i]); } // Floyd Warshall for (int k = 1; k <= n; ++k) { for (int i = 1; i <= n; ++i) { for (int j = 1; j <= n; ++j) { dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); } } } int ans = min(dist[1][n] + dist[n][1]); ll u = edges[i].first, v = edges[i].second; if (min(dist[1][n], dist[1][v] + c[i] + dist[u][n]) + min(dist[n][1], dist[n][v] + c[i] + dist[u][1]) + d[i] < ans) { adj[u].erase(adj[u].find({v, i})); adj[v].insert({u, i}); ans = min(ans, d[i] + dijkstra(1)[n] + dijkstra(n)[1]); adj[v].erase(adj[v].find({edges[i].first, i})); adj[u].insert({v, i}); } if (ans == (int)(1e15)) { ans = -1; } cout << ans; }

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

ho_t4.cpp: In function 'int main()':
ho_t4.cpp:38:19: error: 'll' was not declared in this scope
   38 |     vector<vector<ll>> dist(n + 1, vector<ll>(n + 1, 1e15));
      |                   ^~
ho_t4.cpp:38:19: error: template argument 1 is invalid
ho_t4.cpp:38:19: error: template argument 2 is invalid
ho_t4.cpp:38:21: error: template argument 1 is invalid
   38 |     vector<vector<ll>> dist(n + 1, vector<ll>(n + 1, 1e15));
      |                     ^~
ho_t4.cpp:38:21: error: template argument 2 is invalid
ho_t4.cpp:38:45: error: template argument 2 is invalid
   38 |     vector<vector<ll>> dist(n + 1, vector<ll>(n + 1, 1e15));
      |                                             ^
ho_t4.cpp:38:59: error: expression list treated as compound expression in initializer [-fpermissive]
   38 |     vector<vector<ll>> dist(n + 1, vector<ll>(n + 1, 1e15));
      |                                                           ^
ho_t4.cpp:39:12: error: expected ';' before 'i'
   39 |     for (ll i = 1; i <= n; ++i) {
      |            ^~
      |            ;
ho_t4.cpp:39:20: error: 'i' was not declared in this scope
   39 |     for (ll i = 1; i <= n; ++i) {
      |                    ^
ho_t4.cpp:48:13: error: invalid types 'int[long long int]' for array subscript
   48 |         dist[u][v] = min(dist[u][v], c[i]);
      |             ^
ho_t4.cpp:48:30: error: invalid types 'int[long long int]' for array subscript
   48 |         dist[u][v] = min(dist[u][v], c[i]);
      |                              ^
ho_t4.cpp:55:21: error: invalid types 'int[long long int]' for array subscript
   55 |                 dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      |                     ^
ho_t4.cpp:55:38: error: invalid types 'int[long long int]' for array subscript
   55 |                 dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      |                                      ^
ho_t4.cpp:55:50: error: invalid types 'int[long long int]' for array subscript
   55 |                 dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      |                                                  ^
ho_t4.cpp:55:63: error: invalid types 'int[long long int]' for array subscript
   55 |                 dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      |                                                               ^
ho_t4.cpp:60:23: error: invalid types 'int[int]' for array subscript
   60 |     int ans = min(dist[1][n] + dist[n][1]);
      |                       ^
ho_t4.cpp:60:36: error: invalid types 'int[long long int]' for array subscript
   60 |     int ans = min(dist[1][n] + dist[n][1]);
      |                                    ^
ho_t4.cpp:61:7: error: expected ';' before 'u'
   61 |     ll u = edges[i].first, v = edges[i].second;
      |       ^~
      |       ;
ho_t4.cpp:63:17: error: invalid types 'int[int]' for array subscript
   63 |     if (min(dist[1][n], dist[1][v] + c[i] + dist[u][n]) +
      |                 ^
ho_t4.cpp:63:29: error: invalid types 'int[int]' for array subscript
   63 |     if (min(dist[1][n], dist[1][v] + c[i] + dist[u][n]) +
      |                             ^
ho_t4.cpp:63:33: error: 'v' was not declared in this scope
   63 |     if (min(dist[1][n], dist[1][v] + c[i] + dist[u][n]) +
      |                                 ^
ho_t4.cpp:63:40: error: 'i' was not declared in this scope
   63 |     if (min(dist[1][n], dist[1][v] + c[i] + dist[u][n]) +
      |                                        ^
ho_t4.cpp:63:50: error: 'u' was not declared in this scope
   63 |     if (min(dist[1][n], dist[1][v] + c[i] + dist[u][n]) +
      |                                                  ^
ho_t4.cpp:64:17: error: invalid types 'int[long long int]' for array subscript
   64 |         min(dist[n][1], dist[n][v] + c[i] + dist[u][1]) + d[i] < ans) {
      |                 ^
ho_t4.cpp:64:29: error: invalid types 'int[long long int]' for array subscript
   64 |         min(dist[n][1], dist[n][v] + c[i] + dist[u][1]) + d[i] < ans) {
      |                             ^