제출 #682040

#제출 시각아이디문제언어결과실행 시간메모리
682040kymCommuter Pass (JOI18_commuter_pass)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define FOR(i,s,e) for(int i = s; i <= (int)e; ++i) #define DEC(i,s,e) for(int i = s; i >= (int)e; --i) #define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0); #ifdef LOCAL #define db(x) cerr << #x << "=" << x << "\n" #define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n" #define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n" #define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n" #define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{" << ite.f << ',' << ite.s << "} "; cerr << "\n" #define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n" #define reach cerr << "LINE: " << __LINE__ << "\n"; #else #define reach #define db(x) #define db2(x,y) #define db3(a,b,c) #define dbv(v) #define dbvp(v) #define dba(a,ss,ee) #endif mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define pb push_back #define eb emplace_back #define all(x) (x).begin(), (x).end() #define f first #define s second #define g0(x) get<0>(x) #define g1(x) get<1>(x) #define g2(x) get<2>(x) #define g3(x) get<3>(x) typedef pair <int, int> pi; typedef tuple<int,int,int> ti3; typedef tuple<int,int,int,int> ti4; int rand(int a, int b) { return a + rng() % (b-a+1); } const int MOD = 1e9 + 7; const int inf = (int)1e9 + 500; const long long oo = (long long)1e18 + 500; template <typename T> bool chmax(T& a, const T b) { return a<b ? a = b, 1 : 0; } template <typename T> bool chmin(T& a, const T b) { return a>b ? a = b, 1 : 0; } const int MAXN = 200005; int n,m; int s,t; int u,v; vector<pi> adj[MAXN]; int dist[MAXN][2]; int D1[MAXN], Dn[MAXN]; typedef pair<int,pi> pii; void dij(int source, int * dist) { FOR(i,0,n)dist[i]=oo; dist[source] = 0; priority_queue<pi,vector<pi>,greater<pi>> pq; pq.push({0, source}); while(pq.size()) { pi c=pq.top(); pq.pop(); int x=c.s, d=c.f; if(dist[x]!=d)continue; for(auto v:adj[x]) { int nd=v.s+d; int nx=v.f; if(dist[nx]>nd) { dist[nx]=nd; pq.push({nd,nx}); } } } } int32_t main() { IAMSPEED cin >> n >> m; cin >> s >> t; cin >> u >> v; FOR(i,1,m){ int a,b,c;cin>>a>>b>>c; E[i]={a,b,c}; adj[a].pb({b,c}); adj[b].pb({a,c}); } dij(s,D1); dij(t,Dn); FOR(i,0,n)FOR(j,0,1)dist[i][j]=oo; priority_queue<pii,vector<pii>,greater<pii>>pq; dist[u][0]=0; dist[u][1]=0; pq.push({0,{u,0}}); pq.push({0,{u,1}}); while(pq.size()) { pii c=pq.top(); pq.pop(); int d=c.f, x=c.s.f, y=c.s.s; db3(x,y,d); if(dist[x][y]!=d)continue; for(auto v:adj[x]) { int nx=v.f; if(y == 0) { // increasing path bool on=(D1[t] == D1[x] + v.s + Dn[nx]); // this path is part of commuter pass if(on) { if(chmin(dist[nx][y],dist[x][y])) { pq.push({dist[nx][y], {nx, y}}); } } else { if(chmin(dist[nx][y],dist[x][y] + v.s)) { pq.push({dist[nx][y], {nx,y}}); } } } else { bool on=(Dn[s] == Dn[x] + v.s + D1[nx]); if(on) { if(chmin(dist[nx][y],dist[x][y])) { pq.push({dist[nx][y], {nx, y}}); } } else { if(chmin(dist[nx][y],dist[x][y] + v.s)) { pq.push({dist[nx][y], {nx,y}}); } } } } } cout << min(dist[v][0], dist[v][1]); }

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

commuter_pass.cpp: In function 'int32_t main()':
commuter_pass.cpp:78:3: error: 'E' was not declared in this scope
   78 |   E[i]={a,b,c};
      |   ^