Submission #106751

#TimeUsernameProblemLanguageResultExecution timeMemory
106751kig9981Travelling Merchant (APIO17_merchant)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #ifdef NON_SUBMIT #define TEST(n) (n) #define tout cerr #else #define TEST(n) ((void)0) #define tout cin #endif using namespace std; vector<vector<pair<int,int>>> I; long long D[500][500], C[500][500]; long long comp(long long u1, long long d1, long long u2, long long d2) { return u1*d2-u2*d1; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); TEST(freopen("input.txt","r",stdin)); TEST(freopen("output.txt","w",stdout)); TEST(freopen("debug.txt","w",stderr)); int N, M, K; long long a1=0, a2=1; cin>>N>>M>>K; I.resize(N); memset(D,0x3f,sizeof(D)); for(int i=0;i<N;i++) { I[i].resize(K); for(int k=0;k<K;k++) { cin>>I[i][k].first>>I[i][k].second; for(int j=0;j<i;j++) { if(I[i][k].first!=-1) C[i][j]=max(C[i][j],1LL*I[j][k].second-I[i][k].first); if(I[j][k].first!=-1) C[j][i]=max(C[j][i],1LL*I[i][k].second-I[j][k].first); } } } } while(M--) { int a, b, w; cin>>a>>b>>w; --a; --b; D[a][b]=min(D[a][b],1LL*w); } 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 k=0;k<N;k++) for(int i=0;i<N;i++) for(int j=0;j<N;j++) { if(comp(C[i][j],D[i][j],C[i][k]+C[k][j],D[i][k]+D[k][j])<0) { C[i][j]=C[i][k]+C[k][j]; D[i][j]=D[i][k]+D[k][j]; } } for(int i=0;i<N;i++) if(comp(a1,a2,C[i][i],D[i][i])<0) { a1=C[i][i]; a2=D[i][i]; } cout<<a1/a2<<'\n'; return 0; }

Compilation message (stderr)

merchant.cpp: In function 'int main()':
merchant.cpp:29:12: warning: unused variable 'a1' [-Wunused-variable]
  long long a1=0, a2=1;
            ^~
merchant.cpp:29:18: warning: unused variable 'a2' [-Wunused-variable]
  long long a1=0, a2=1;
                  ^~
merchant.cpp: At global scope:
merchant.cpp:44:2: error: expected unqualified-id before 'while'
  while(M--) {
  ^~~~~
merchant.cpp:49:2: error: expected unqualified-id before 'for'
  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]);
  ^~~
merchant.cpp:49:14: error: 'k' does not name a type
  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]);
              ^
merchant.cpp:49:18: error: 'k' does not name a type
  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]);
                  ^
merchant.cpp:49:35: error: 'i' does not name a type
  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]);
                                   ^
merchant.cpp:49:39: error: 'i' does not name a type
  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]);
                                       ^
merchant.cpp:49:56: error: 'j' does not name a type
  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]);
                                                        ^
merchant.cpp:49:60: error: 'j' does not name a type
  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]);
                                                            ^
merchant.cpp:50:2: error: expected unqualified-id before 'for'
  for(int k=0;k<N;k++) for(int i=0;i<N;i++) for(int j=0;j<N;j++) {
  ^~~
merchant.cpp:50:14: error: 'k' does not name a type
  for(int k=0;k<N;k++) for(int i=0;i<N;i++) for(int j=0;j<N;j++) {
              ^
merchant.cpp:50:18: error: 'k' does not name a type
  for(int k=0;k<N;k++) for(int i=0;i<N;i++) for(int j=0;j<N;j++) {
                  ^
merchant.cpp:50:35: error: 'i' does not name a type
  for(int k=0;k<N;k++) for(int i=0;i<N;i++) for(int j=0;j<N;j++) {
                                   ^
merchant.cpp:50:39: error: 'i' does not name a type
  for(int k=0;k<N;k++) for(int i=0;i<N;i++) for(int j=0;j<N;j++) {
                                       ^
merchant.cpp:50:56: error: 'j' does not name a type
  for(int k=0;k<N;k++) for(int i=0;i<N;i++) for(int j=0;j<N;j++) {
                                                        ^
merchant.cpp:50:60: error: 'j' does not name a type
  for(int k=0;k<N;k++) for(int i=0;i<N;i++) for(int j=0;j<N;j++) {
                                                            ^
merchant.cpp:56:2: error: expected unqualified-id before 'for'
  for(int i=0;i<N;i++) if(comp(a1,a2,C[i][i],D[i][i])<0) {
  ^~~
merchant.cpp:56:14: error: 'i' does not name a type
  for(int i=0;i<N;i++) if(comp(a1,a2,C[i][i],D[i][i])<0) {
              ^
merchant.cpp:56:18: error: 'i' does not name a type
  for(int i=0;i<N;i++) if(comp(a1,a2,C[i][i],D[i][i])<0) {
                  ^
merchant.cpp:60:2: error: 'cout' does not name a type; did you mean 'tout'?
  cout<<a1/a2<<'\n';
  ^~~~
  tout
merchant.cpp:61:2: error: expected unqualified-id before 'return'
  return 0;
  ^~~~~~
merchant.cpp:62:1: error: expected declaration before '}' token
 }
 ^