Submission #833168

#TimeUsernameProblemLanguageResultExecution timeMemory
833168vjudge1Commuter Pass (JOI18_commuter_pass)C++98
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define fi first #define se second #define pii pair<ll,ll> const ll N = 1e5+10; ll n,m,u,v,s,t; ll temp,a,b,c; map<ll,bool> iszero[100100]; vector<pii> adj[N]; vector<ll> pass; priority_queue<pii,vector<pii>,greater<pii>> pq; bool vis[N]; ll dist[N],pre[N]; void f(ll x) { if(pre[x] != 0) { f(pre[x]); pass.pb(x); } } int main() { cin >> n >> m; cin >> s >> t; cin >> u >> v; for(int i=1; i<=m; i++) { cin >> a >> b >> c; adj[a].pb({b,c}); adj[b].pb({a,c}); } for(int i=1; i<=n; i++) dist[i] = 1e18; pq.push({0,s}); dist[s] = 0; while(!pq.empty()) { pii x = pq.top(); pq.pop(); for(auto i : adj[x.se]) { if(dist[i.fi] > dist[x.se] + i.se) { dist[i.fi] = dist[x.se] + i.se; pq.push({dist[i.fi],i.fi}); pre[i.fi] = x.se; } } } // cout << "dist " << endl; // for(int i=1; i<=n; i++) { // cout << dist[i] << endl; // } // cout << "prev " << endl; // for(int i=1; i<=n; i++) { // cout << pre[i] << endl; // } pass.pb(s); f(t); // cout << "pass "; // for(auto i : pass) { // cout << i << " "; // } // cout << endl; for(int i=1; i<pass.size(); i++) { iszero[pass[i-1]][pass[i]] = true; } for(int i=1; i<=n; i++) dist[i] = 1e18; pq.push({0,u}); dist[u] = 0; while(!pq.empty()) { pii x = pq.top(); pq.pop(); for(auto i : adj[x.se]) { if(iszero[x.se][i.fi]) temp = 0; else temp = i.se; if(dist[i.fi] > dist[x.se] + temp) { dist[i.fi] = dist[x.se] + temp; pq.push({dist[i.fi],i.fi}); } } } cout << dist[v] << endl; }

Compilation message (stderr)

commuter_pass.cpp:13:27: error: 'std::map<long long int, bool> iszero [100100]' redeclared as different kind of entity
   13 | map<ll,bool> iszero[100100];
      |                           ^
In file included from /usr/include/c++/10/cmath:45,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from commuter_pass.cpp:1:
/usr/include/math.h:1048:1: note: previous declaration 'template<class __T> bool iszero(__T)'
 1048 | iszero (__T __val)
      | ^~~~~~
commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:65:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |  for(int i=1; i<pass.size(); i++) {
      |               ~^~~~~~~~~~~~
commuter_pass.cpp:66:9: error: invalid types '<unresolved overloaded function type>[__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}]' for array subscript
   66 |   iszero[pass[i-1]][pass[i]] = true;
      |         ^
commuter_pass.cpp:75:13: error: invalid types '<unresolved overloaded function type>[long long int]' for array subscript
   75 |    if(iszero[x.se][i.fi]) temp = 0;
      |             ^