제출 #927717

#제출 시각아이디문제언어결과실행 시간메모리
927717Art_ogoCommuter Pass (JOI18_commuter_pass)C++17
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <set> #include <map> #include <algorithm> /* #define int long long */ #define ll long long #define fi first #define se second #define ve vector using namespace std; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define all(x) x.begin(), x.end() const int MAXN = 1e6+10; ve<pll> g[MAXN]; ve<ll> ds, da, db; ll dpl[MAXN], dpr[MAXN], dp[MAXN]; bool vis[MAXN]; void djkstra(int s, ve<ll>& d){ set<pll> st; st.insert({0, s}); d[s] = 0; while(!st.empty()){ int v = st.begin()->se; st.erase(st.begin()); for(auto to : g[v]){ if(d[to.fi] > d[v] + to.se){ if(st.find({d[to.fi], to.fi}) != st.end()) st.erase({d[to.fi], to.fi}); d[to.fi] = d[v] + to.se; st.insert({d[to.fi], to.fi}); } } } } void dfsl(int v){ vis[v] = 1; dpl[v] = da[v]; for(auto& to : g[v]){ if(ds[v] - to.se == ds[to.fi]){ if(!vis[to.fi]) dfsl(to.fi); dpl[v] = min(dpl[v], dpl[to.fi]); } } } void dfsr(int v){ vis[v] = 1; dpr[v] = da[v]; for(auto& to : g[v]) if(ds[v] + to.se == ds[to.fi]){ if(!vis[to.fi]) dfsr(to.fi); dpr[v] = min(dpr[v], dpr[to.fi]); } dp[v] = min(dpl[v], dpr[v]); } signed main(){ int n, m; cin >> n >> m; int s, t, a, b; cin >> s >> t >> a >> b; s--; t--; a--; b--; for(int i = 0; i < m; i++){ ll u, v, w; cin >> u >> v >> w; u--; v--; g[u].push_back({v, w}); g[v].push_back({u, w}); } ds.resize(n, 1e18); da.resize(n, 1e18); db.resize(n, 1e18); fill(dpl, dpl + n, 1e18); fill(dpr, dpr + n, 1e18); djkstra(s, ds); djkstra(a, da); djkstra(b, db); dfsl(t); memset(vis, 0, sizeof(vis)); dfsr(s); ll res = da[b]; for(int i = 0; i < n; i++){ res = min(res, dp[i] + db[i]); } cout << res; }

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

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:90:5: error: 'memset' was not declared in this scope
   90 |     memset(vis, 0, sizeof(vis));
      |     ^~~~~~
commuter_pass.cpp:6:1: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
    5 | #include <algorithm>
  +++ |+#include <cstring>
    6 |