제출 #1311737

#제출 시각아이디문제언어결과실행 시간메모리
1311737filip1111Commuter Pass (JOI18_commuter_pass)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = long long; const int N = 1e5 + 99; vector<pair<int,ll>>tab[N]; const ll inf = 1e18; ll odl[N]; ll dijkstra(int a, int b, int n){ for(int i = 0; i < n+ 9; ++i)odl[i] = inf; priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> pq; pq.push({0,a}); while(!pq.empty()){ auto[x,v] = pq.top(); pq.pop(); if(odl[v] <= x)continue; odl[v] = x; for(auto [u,y] : tab[v]){ pq.push({x+y,u}); } } return odl[b]; } ll odl2[N][3]; int S,T, U, V; struct PairHash { size_t operator()(const pair<int,int>& p) const { return ((size_t)p.first << 32) ^ (size_t)p.second; } }; unordered_map<pair<int,int>, int, PairHash> Star; ll dijkstra2(int a,int b,int n){ for(int i = 0; i < n + 9; i++){ odl2[i][0] = odl2[i][1] = odl2[i][2] = inf; } priority_queue<pair<ll,pair<int,int>>, vector<pair<ll,pair<int,int>>>, greater<pair<ll,pair<int,int>>>> pq; pq.push({0,{a,0}}); while(!pq.empty()){ auto[x, p1] = pq.top(); pq.pop(); auto[v, l] = p1; if(l > 2)continue; // if(v == 2 && l == 0){ // cout << "Xd" << x << endl; // } if(odl2[v][l] <= x)continue; odl2[v][l] = x; for(auto [u,w] : tab[v]){ // if(v == 2 && u == 4){ // cout << "x + STar[{u,v}]" << " " << x + Star[{u,v}] << endl; // cout << x << " " << " lol " << Star[{u,v}] << endl; // } pq.push({x+Star[{u,v}],{u,l}}); if(l == 0){ if(w == 0)pq.push({x,{u,1}}); } else if(l == 1){ if(w == 0 )pq.push({x,{u,1}}); } } } return min(min(odl2[b][1],odl2[b][0]),odl2[b][2]); } bool vis[N]; map<pair<int,int>,bool>M; void dfs(int v, ll x){ assert(odl[v] == x); if(x == 0)return; if(vis[v])return; vis[v] = 1; ll mini = inf; for(auto [u,y] : tab[v]){ mini = min(mini, odl[u] + y); } for(auto [u, y] : tab[v]){ if(mini == odl[u] + y){ dfs(u,x - y); M[{v,u}]=1; // M[{u,v}]=1; } } } int main(){ int n, m; cin >> n >> m; cin >> S >> T >> U >> V; for(int i = 0; i < m; i++){ int a, b, c; cin >> a >> b >> c; tab[a].push_back({b,c}); assert(Star[{a,b}]==0); Star[{a,b}] = c; Star[{b,a}] = c; tab[b].push_back({a,c}); } ll oo = dijkstra(S,T,n); dfs(T,oo); for(int i = 1; i <= n; i++){ for(auto &[v,x] : tab[i]){ if(M[{i,v}])x = 0; else x = Star[{i,v}]; } } ll ooo = dijkstra2(U,V,n); for(int i = 1; i <= n; i++){ for(auto &[v,x] : tab[i]){ if(M[{v,i}])x = 0; else x = Star[{i,v}]; } } ll oooo = dijkstra2(U,V, n); cout << min(ooo,oooo) << endl; }

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

commuter_pass.cpp:95:30: error: macro "assert" passed 2 arguments, but takes just 1
   95 |         assert(Star[{a,b}]==0);
      |                              ^
In file included from /usr/include/c++/13/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:106,
                 from commuter_pass.cpp:1:
/usr/include/assert.h:102: note: macro "assert" defined here
  102 | #  define assert(expr)                                                  \
      | 
commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:95:9: error: 'assert' was not declared in this scope
   95 |         assert(Star[{a,b}]==0);
      |         ^~~~~~
commuter_pass.cpp:2:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
    1 | #include <bits/stdc++.h>
  +++ |+#include <cassert>
    2 | using namespace std;