제출 #772605

#제출 시각아이디문제언어결과실행 시간메모리
772605RecursiveCoCommuter Pass (JOI18_commuter_pass)C++14
24 / 100
150 ms262144 KiB
// CF template, version 3.0 #include <bits/stdc++.h> using namespace std; #define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0) #define getTest int t; cin >> t #define eachTest for (int _var=0;_var<t;_var++) #define get(name) int (name); cin >> (name) #define out(o) cout << (o) #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); } #define sortl(name) sort((name).begin(), (name).end()) #define rev(name) reverse((name).begin(), (name).end()) #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++) #define decision(b) if (b){out("YES");}else{out("NO");} #define int long long int vector<vector<pair<int, int>>> adjList; int n; vector<int> dijkstra(int v) { vector<bool> visited(n, false); vector<int> shortest(n, 1e18); priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; pq.push({0, v}); while (!pq.empty()) { auto top = pq.top(); pq.pop(); if (visited[top.second]) continue; visited[top.second] = true; shortest[top.second] = min(shortest[top.second], top.first); for (auto con: adjList[top.second]) { if (!visited[con.first]) pq.push({shortest[top.second] + con.second, con.first}); } } return shortest; } signed main() { improvePerformance; cin >> n; get(m); get(s); get(t); get(u); get(v); s--; t--; u--; v--; adjList.resize(n); forto(m, i) { get(a); get(b); get(w); a--; b--; adjList[a].push_back({b, w}); adjList[b].push_back({a, w}); } vector<vector<int>> d(n, vector<int>(n, 1e18)); forto(n, i) d[i][i] = 0; forto(n, i) for (auto con: adjList[i]) d[i][con.first] = con.second; forto(n, k) { forto(n, i) { forto(n, j) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } int ans = d[u][v]; forto(n, x) { forto(n, y) { if (d[s][x] + d[x][y] + d[y][t] == d[s][t]) { ans = min(ans, min(d[u][x] + d[y][v], d[u][y] + d[x][v])); } } } out(ans); }

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

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:10:23: warning: unnecessary parentheses in declaration of 'm' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
commuter_pass.cpp:44:5: note: in expansion of macro 'get'
   44 |     get(m);
      |     ^~~
commuter_pass.cpp:10:23: warning: unnecessary parentheses in declaration of 's' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
commuter_pass.cpp:45:5: note: in expansion of macro 'get'
   45 |     get(s);
      |     ^~~
commuter_pass.cpp:10:23: warning: unnecessary parentheses in declaration of 't' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
commuter_pass.cpp:46:5: note: in expansion of macro 'get'
   46 |     get(t);
      |     ^~~
commuter_pass.cpp:10:23: warning: unnecessary parentheses in declaration of 'u' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
commuter_pass.cpp:47:5: note: in expansion of macro 'get'
   47 |     get(u);
      |     ^~~
commuter_pass.cpp:10:23: warning: unnecessary parentheses in declaration of 'v' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
commuter_pass.cpp:48:5: note: in expansion of macro 'get'
   48 |     get(v);
      |     ^~~
commuter_pass.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
commuter_pass.cpp:54:5: note: in expansion of macro 'forto'
   54 |     forto(m, i) {
      |     ^~~~~
commuter_pass.cpp:10:23: warning: unnecessary parentheses in declaration of 'a' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
commuter_pass.cpp:55:9: note: in expansion of macro 'get'
   55 |         get(a);
      |         ^~~
commuter_pass.cpp:10:23: warning: unnecessary parentheses in declaration of 'b' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
commuter_pass.cpp:56:9: note: in expansion of macro 'get'
   56 |         get(b);
      |         ^~~
commuter_pass.cpp:10:23: warning: unnecessary parentheses in declaration of 'w' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
commuter_pass.cpp:57:9: note: in expansion of macro 'get'
   57 |         get(w);
      |         ^~~
commuter_pass.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
commuter_pass.cpp:65:5: note: in expansion of macro 'forto'
   65 |     forto(n, i) d[i][i] = 0;
      |     ^~~~~
commuter_pass.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
commuter_pass.cpp:66:5: note: in expansion of macro 'forto'
   66 |     forto(n, i) for (auto con: adjList[i]) d[i][con.first] = con.second;
      |     ^~~~~
commuter_pass.cpp:15:35: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
commuter_pass.cpp:67:5: note: in expansion of macro 'forto'
   67 |     forto(n, k) {
      |     ^~~~~
commuter_pass.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
commuter_pass.cpp:68:9: note: in expansion of macro 'forto'
   68 |         forto(n, i) {
      |         ^~~~~
commuter_pass.cpp:15:35: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
commuter_pass.cpp:69:13: note: in expansion of macro 'forto'
   69 |             forto(n, j) {
      |             ^~~~~
commuter_pass.cpp:15:35: warning: unnecessary parentheses in declaration of 'x' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
commuter_pass.cpp:75:5: note: in expansion of macro 'forto'
   75 |     forto(n, x) {
      |     ^~~~~
commuter_pass.cpp:15:35: warning: unnecessary parentheses in declaration of 'y' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
commuter_pass.cpp:76:9: note: in expansion of macro 'forto'
   76 |         forto(n, y) {
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...