Submission #73371

# Submission time Handle Problem Language Result Execution time Memory
73371 2018-08-28T07:56:43 Z FedericoS Travelling Merchant (APIO17_merchant) C++14
Compilation error
0 ms 0 KB
#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;*/

Compilation message

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