제출 #744446

#제출 시각아이디문제언어결과실행 시간메모리
744446Mauve여행하는 상인 (APIO17_merchant)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define ss second #define ff first #define ll 1000000000000000 #define pb push_back ll n,m,l,r,i,j,ii,jj,k,x,y,T,s,e,adj[101][101],ashig[101][101],adj1[101][101],buy[101][1001],sell[101][1001]; bool floyd_warshall(ll graph[101][101]){ for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) for(int k=1;k<=n;k++) graph[j][k]=min(graph[j][k],graph[j][i]+graph[i][k]); for(int i=1;i<=n;i++) if(graph[i][i]<=0) return true; return false; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin>>n>>m>>k; for(i=1;i<=n;i++) for(j=1;j<=k;j++) cin>>buy[i][j]>>sell[i][j]; for(i=1;i<=n;i++) for(j=1;j<=n;j++) adj[i][j]=INF; for(i=1;i<=m;i++){ cin>>l>>r>>e; adj[l][r]=e; } floyd_warshall(adj); for(i=1;i<=n;i++) for(j=1;j<=n;j++) for(ii=1;ii<=k;ii++) if(buy[i][ii]!=-1 && sell[j][ii]!=-1) ashig[i][j]=max(ashig[i][j],sell[j][ii]-buy[i][ii]); l=0; r=1e9; while(r-l>1){ m=(r+l)/2; for(i=1;i<=n;i++) for(j=1;j<=n;j++) adj1[i][j]=m*min(adj[i][j],(INF)/m)-ashig[i][j]; if(floyd_warshall(adj1)) l=m; else r=m-1; } for(i=1;i<=n;i++) for(j=1;j<=n;j++) adj1[i][j]=min(adj[i][j],(INF)/r)*r-ashig[i][j]; if(floyd_warshall(adj1)) cout<<r; else cout<<l; }

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

merchant.cpp:6: warning: "ll" redefined
    6 | #define ll 1000000000000000
      | 
merchant.cpp:3: note: this is the location of the previous definition
    3 | #define ll long long
      | 
merchant.cpp:6:12: error: expected unqualified-id before numeric constant
    6 | #define ll 1000000000000000
      |            ^~~~~~~~~~~~~~~~
merchant.cpp:8:1: note: in expansion of macro 'll'
    8 | ll n,m,l,r,i,j,ii,jj,k,x,y,T,s,e,adj[101][101],ashig[101][101],adj1[101][101],buy[101][1001],sell[101][1001];
      | ^~
merchant.cpp:9:24: error: expected ')' before 'graph'
    9 | bool floyd_warshall(ll graph[101][101]){
      |                    ~   ^~~~~
merchant.cpp:9:40: error: expected ',' or ';' before '{' token
    9 | bool floyd_warshall(ll graph[101][101]){
      |                                        ^
merchant.cpp: In function 'int main()':
merchant.cpp:21:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   21 |     cin>>n>>m>>k;
      |          ^
      |          yn
merchant.cpp:21:13: error: 'm' was not declared in this scope; did you mean 'tm'?
   21 |     cin>>n>>m>>k;
      |             ^
      |             tm
merchant.cpp:21:16: error: 'k' was not declared in this scope
   21 |     cin>>n>>m>>k;
      |                ^
merchant.cpp:22:9: error: 'i' was not declared in this scope
   22 |     for(i=1;i<=n;i++)
      |         ^
merchant.cpp:23:9: error: 'j' was not declared in this scope; did you mean 'jn'?
   23 |     for(j=1;j<=k;j++)
      |         ^
      |         jn
merchant.cpp:24:10: error: 'buy' was not declared in this scope
   24 |     cin>>buy[i][j]>>sell[i][j];
      |          ^~~
merchant.cpp:24:21: error: 'sell' was not declared in this scope
   24 |     cin>>buy[i][j]>>sell[i][j];
      |                     ^~~~
merchant.cpp:25:9: error: 'i' was not declared in this scope
   25 |     for(i=1;i<=n;i++) for(j=1;j<=n;j++) adj[i][j]=INF;
      |         ^
merchant.cpp:25:27: error: 'j' was not declared in this scope; did you mean 'jn'?
   25 |     for(i=1;i<=n;i++) for(j=1;j<=n;j++) adj[i][j]=INF;
      |                           ^
      |                           jn
merchant.cpp:25:41: error: 'adj' was not declared in this scope
   25 |     for(i=1;i<=n;i++) for(j=1;j<=n;j++) adj[i][j]=INF;
      |                                         ^~~
merchant.cpp:25:51: error: 'INF' was not declared in this scope
   25 |     for(i=1;i<=n;i++) for(j=1;j<=n;j++) adj[i][j]=INF;
      |                                                   ^~~
merchant.cpp:26:9: error: 'i' was not declared in this scope
   26 |     for(i=1;i<=m;i++){
      |         ^
merchant.cpp:27:14: error: 'l' was not declared in this scope; did you mean 'll'?
   27 |         cin>>l>>r>>e;
      |              ^
      |              ll
merchant.cpp:27:17: error: 'r' was not declared in this scope
   27 |         cin>>l>>r>>e;
      |                 ^
merchant.cpp:27:20: error: 'e' was not declared in this scope
   27 |         cin>>l>>r>>e;
      |                    ^
merchant.cpp:28:9: error: 'adj' was not declared in this scope
   28 |         adj[l][r]=e;
      |         ^~~
merchant.cpp:30:20: error: 'adj' was not declared in this scope
   30 |     floyd_warshall(adj);
      |                    ^~~
merchant.cpp:30:23: error: 'floyd_warshall' cannot be used as a function
   30 |     floyd_warshall(adj);
      |                       ^
merchant.cpp:31:9: error: 'i' was not declared in this scope
   31 |     for(i=1;i<=n;i++)
      |         ^
merchant.cpp:32:9: error: 'j' was not declared in this scope; did you mean 'jn'?
   32 |     for(j=1;j<=n;j++)
      |         ^
      |         jn
merchant.cpp:33:9: error: 'ii' was not declared in this scope
   33 |     for(ii=1;ii<=k;ii++)
      |         ^~
merchant.cpp:34:8: error: 'buy' was not declared in this scope
   34 |     if(buy[i][ii]!=-1 && sell[j][ii]!=-1) ashig[i][j]=max(ashig[i][j],sell[j][ii]-buy[i][ii]);
      |        ^~~
merchant.cpp:34:26: error: 'sell' was not declared in this scope
   34 |     if(buy[i][ii]!=-1 && sell[j][ii]!=-1) ashig[i][j]=max(ashig[i][j],sell[j][ii]-buy[i][ii]);
      |                          ^~~~
merchant.cpp:34:43: error: 'ashig' was not declared in this scope
   34 |     if(buy[i][ii]!=-1 && sell[j][ii]!=-1) ashig[i][j]=max(ashig[i][j],sell[j][ii]-buy[i][ii]);
      |                                           ^~~~~
merchant.cpp:35:5: error: 'l' was not declared in this scope; did you mean 'll'?
   35 |     l=0;
      |     ^
      |     ll
merchant.cpp:36:5: error: 'r' was not declared in this scope
   36 |     r=1e9;
      |     ^
merchant.cpp:39:13: error: 'i' was not declared in this scope
   39 |         for(i=1;i<=n;i++)
      |             ^
merchant.cpp:40:13: error: 'j' was not declared in this scope; did you mean 'jn'?
   40 |         for(j=1;j<=n;j++)
      |             ^
      |             jn
merchant.cpp:41:9: error: 'adj1' was not declared in this scope; did you mean 'j1'?
   41 |         adj1[i][j]=m*min(adj[i][j],(INF)/m)-ashig[i][j];
      |         ^~~~
      |         j1
merchant.cpp:41:37: error: 'INF' was not declared in this scope
   41 |         adj1[i][j]=m*min(adj[i][j],(INF)/m)-ashig[i][j];
      |                                     ^~~
merchant.cpp:41:45: error: 'ashig' was not declared in this scope
   41 |         adj1[i][j]=m*min(adj[i][j],(INF)/m)-ashig[i][j];
      |                                             ^~~~~
merchant.cpp:42:27: error: 'adj1' was not declared in this scope; did you mean 'j1'?
   42 |         if(floyd_warshall(adj1)) l=m;
      |                           ^~~~
      |                           j1
merchant.cpp:42:31: error: 'floyd_warshall' cannot be used as a function
   42 |         if(floyd_warshall(adj1)) l=m;
      |                               ^
merchant.cpp:45:9: error: 'i' was not declared in this scope
   45 |     for(i=1;i<=n;i++)
      |         ^
merchant.cpp:46:9: error: 'j' was not declared in this scope; did you mean 'jn'?
   46 |     for(j=1;j<=n;j++) adj1[i][j]=min(adj[i][j],(INF)/r)*r-ashig[i][j];
      |         ^
      |         jn
merchant.cpp:46:23: error: 'adj1' was not declared in this scope; did you mean 'j1'?
   46 |     for(j=1;j<=n;j++) adj1[i][j]=min(adj[i][j],(INF)/r)*r-ashig[i][j];
      |                       ^~~~
      |                       j1
merchant.cpp:46:49: error: 'INF' was not declared in this scope
   46 |     for(j=1;j<=n;j++) adj1[i][j]=min(adj[i][j],(INF)/r)*r-ashig[i][j];
      |                                                 ^~~
merchant.cpp:46:59: error: 'ashig' was not declared in this scope
   46 |     for(j=1;j<=n;j++) adj1[i][j]=min(adj[i][j],(INF)/r)*r-ashig[i][j];
      |                                                           ^~~~~
merchant.cpp:47:23: error: 'adj1' was not declared in this scope; did you mean 'j1'?
   47 |     if(floyd_warshall(adj1)) cout<<r;
      |                       ^~~~
      |                       j1
merchant.cpp:47:27: error: 'floyd_warshall' cannot be used as a function
   47 |     if(floyd_warshall(adj1)) cout<<r;
      |                           ^