제출 #73371

#제출 시각아이디문제언어결과실행 시간메모리
73371FedericoS여행하는 상인 (APIO17_merchant)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> using namespace std; int INF=1e9; int N,M,K; int x,y; int C[100][1005][2]; int D[105][105]; int P[105][105]; int DP[55][55][55]; int main(){ cin>>N>>M>>K; for(int i=0;i<N;i++) for(int j=0;j<K;j++) cin>>C[i][j][0]>>C[i][j][1]; for(int i=0;i<N;i++) for(int j=0;j<N;j++) D[i][j]=(i==j)?0:INF; for(int i=0;i<M;i++) cin>>x>>y>>D[x-1][y-1]; for(int k=0;k<N;k++) for(int i=0;i<N;i++) for(int j=0;j<N;j++) D[i][j]=min(D[i][j],D[i][k]+D[k][j]); for(int a=0;a<N;a++) for(int b=0;b<N;b++) for(int j=0;j<K;j++) if(C[a][j][0]!=-1 and C[b][j][1]!=-1) P[a][b]=max(P[a][b],C[b][j][1]-C[a][j][0]); for(int a=0;a<N,a++) for(int b=0;b<N;b++) if(a!=b) DP[a][b][1]=P[a][b]; for(int k=2;k<N;k++) for(int a=0;a<N,a++) for(int b=0;b<N;b++) for(int c=0;c<N;c++) if(a!=b and b!=c and a!=c) DP[a][b][k]=DP[a][c][k-1]+DP[c][b][1]; for(int a=0;a<N,a++) for(int b=0;b<N;b++) for(int i=1;i<N;i++) for(int j=1;j<N;j++) ans=max(ans,(DP[a][b][i]+DP[b][a][j])/(i+j)); /* int ans=0; for(int i=1;i<N;i++) ans=max(ans,(P[0][i]+P[i][0])/(D[0][i]+D[i][0])); */ cout<<ans; } /*for(int a=0;a<N;a++) for(int b=0;b<N;b++) cout<<a<<" "<<b<<" "<<P[a][b]<<endl;*/

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

merchant.cpp: In function 'int main()':
merchant.cpp:37:15: warning: left operand of comma operator has no effect [-Wunused-value]
  for(int a=0;a<N,a++)
              ~^~
merchant.cpp:37:21: error: expected ';' before ')' token
  for(int a=0;a<N,a++)
                     ^
merchant.cpp:43:16: warning: left operand of comma operator has no effect [-Wunused-value]
   for(int a=0;a<N,a++)
               ~^~
merchant.cpp:43:22: error: expected ';' before ')' token
   for(int a=0;a<N,a++)
                      ^
merchant.cpp:49:15: warning: left operand of comma operator has no effect [-Wunused-value]
  for(int a=0;a<N,a++)
              ~^~
merchant.cpp:49:21: error: expected ';' before ')' token
  for(int a=0;a<N,a++)
                     ^
merchant.cpp:53:6: error: 'ans' was not declared in this scope
      ans=max(ans,(DP[a][b][i]+DP[b][a][j])/(i+j));
      ^~~
merchant.cpp:53:6: note: suggested alternative: 'abs'
      ans=max(ans,(DP[a][b][i]+DP[b][a][j])/(i+j));
      ^~~
      abs
merchant.cpp:59:8: error: 'ans' was not declared in this scope
  cout<<ans;
        ^~~
merchant.cpp:59:8: note: suggested alternative: 'abs'
  cout<<ans;
        ^~~
        abs