제출 #321554

#제출 시각아이디문제언어결과실행 시간메모리
321554YJUOlympic Bus (JOI20_ho_t4)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #pragma GCC optimize("unroll-loops,no-stack-protector") using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll,ll> pll; const ll MOD=1e9+7; const ll MOD2=998244353; const ll N=2e2+5; const ll M=5e5+5; const ld pi=3.14159265359; const ll INF=(1LL<<59); #define SQ(i) ((i)*(i)) #define REP(i,n) for(ll i=0;i<n;i++) #define REP1(i,n) for(ll i=1;i<=n;i++) #define pb push_back #define mp make_pair #define X first #define Y second #define setp setprecision #define lwb lower_bound #define SZ(_a) (ll)_a.size() pll ed[M]; ll n,m,c[M],d[M],from[N]; vector<pll> v[N],rv[N]; ll dist[2][2][N],x,y,dis[2][2][N]; priority_queue<pll,vector<pll> ,greater<pll> > pq; void dij(ll start,ll D[][],ll id){ REP(i,2)REP1(j,n)D[i][j]=INF; pq.push(mp(D[0][1]=0,start)); while(SZ(pq)){ x=pq.top().Y;y=pq.top().X;pq.pop(); if(y>D[0][x])continue; for(pll i:v[x]){ if(i.Y==id)continue; if(D[0][i.X]>D[0][x]+c[i.Y]){ pq.push(mp(D[0][i.X]=D[0][x]+c[i.Y],i.X)); } } } pq.push(mp(D[1][n]=0,n+1-start)); while(SZ(pq)){ x=pq.top().Y;y=pq.top().X;pq.pop(); if(y>D[1][x])continue; for(pll i:rv[x]){ if(i.Y==id)continue; if(D[1][i.X]>D[1][x]+c[i.Y]){ pq.push(mp(D[1][i.X]=D[1][x]+c[i.Y],i.X)); } } } } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>m; REP1(i,m){ cin>>ed[i].X>>ed[i].Y>>c[i]>>d[i]; v[ed[i].X].pb(mp(ed[i].Y,i)); rv[ed[i].Y].pb(mp(ed[i].X,i)); } dij(1,dis[0],0); dij(n,dis[1],0); ans=dis[0][0][n]+dis[1][0][1]; REP1(i,m){ if(from[ed[i].Y]==i){ dij(1,dist[0],i); dij(n,dist[1],i); ans=min(ans,d[i]+min(dist[0][0][n],dist[0][0][ed[i].Y]+c[i]+dist[0][1][ed[i].X])+min(dist[1][0][1],dist[1][0][ed[i].Y]+c[i]+dist[1][1][ed[i].X])); }else{ ans=min(ans,d[i]+min(dis[0][0][n],dis[0][0][ed[i].Y]+c[i]+dis[0][1][ed[i].X])+min(dis[1][0][1],dis[1][0][ed[i].Y]+c[i]+dis[1][1][ed[i].X])); } } cout<<(ans>=INF?-1:ans)<<"\n"; return 0; }

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

ho_t4.cpp:31:22: error: declaration of 'D' as multidimensional array must have bounds for all dimensions except the first
   31 | void dij(ll start,ll D[][],ll id){
      |                      ^
ho_t4.cpp:31:27: error: expected ')' before ',' token
   31 | void dij(ll start,ll D[][],ll id){
      |         ~                 ^
      |                           )
ho_t4.cpp:31:31: error: expected initializer before 'id'
   31 | void dij(ll start,ll D[][],ll id){
      |                               ^~
ho_t4.cpp: In function 'int main()':
ho_t4.cpp:69:2: error: 'ans' was not declared in this scope; did you mean 'abs'?
   69 |  ans=dis[0][0][n]+dis[1][0][1];
      |  ^~~
      |  abs