제출 #349712

#제출 시각아이디문제언어결과실행 시간메모리
349712TAMREF여행하는 상인 (APIO17_merchant)C++17
0 / 100
888 ms3160 KiB
#include <bits/stdc++.h> #define va first #define vb second #define lb lower_bound #define ub upper_bound #define bs binary_search #define pp push_back #define ep emplace_back #define all(v) (v).begin(),(v).end() #define szz(v) ((int)(v).size()) #define bi_pc __builtin_popcount #define bi_pcll __builtin_popcountll #define bi_tz __builtin_ctz #define bi_tzll __builtin_ctzll #define fio ios_base::sync_with_stdio(0);cin.tie(0); #ifdef TAMREF #define debug(...) fprintf(stderr, __VA_ARGS__) #else #define debug(...) 42 #endif using namespace std; using ll = long long; using lf = long double; using pii = pair<int,int>; using ppi = pair<int,pii>; using pll = pair<ll,ll>; using pff = pair<lf,lf>; using ti = tuple<int,int,int>; using base = complex<double>; const lf PI = 3.14159265358979323846264338L; template <typename T> inline T umax(T& u, T v){return u = max(u, v);} template <typename T> inline T umin(T& u, T v){return u = min(u, v);} mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, m, k; const ll inf = 1e15; ll sp[105][105]; pll tsp[105][105]; vector<int> B[105], S[105]; pll operator+ (pll u, pll v){ return pll(u.va + v.va, u.vb + v.vb); } bool pro(ll x){ for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ if(i == j){ tsp[i][i] = pll(0,0); continue; } tsp[i][j] = pll(inf, 0); for(int t = 0; t <= k; t++){ if(B[i][t] == -1 || S[j][t] == -1) continue; ll cost = sp[i][j] * x - (S[j][t] - B[i][t]); tsp[i][j] = min(tsp[i][j], pll(cost, -sp[i][j])); } } } for(int t = 1; t <= n; t++){ for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ tsp[i][j] = min(tsp[i][j], tsp[i][t] + tsp[t][j]); } } } debug("-------tsp------x = %lld----\n",x); for(int i = 1; i <= n; i++){ for(int j =1 ; j <= n; j++){ debug("(%lld,%lld) ",tsp[i][j].va,tsp[i][j].vb); } debug("\n"); } return tsp[1][1] < pll(0,0); } int main(){ fio; cin >> n >> m >> k; for(int i = 1; i <= n; i++){ fill(sp[i] + 1, sp[i] + n + 1, inf); sp[i][i] = 0; B[i] = vector<int>(k + 1); S[i] = vector<int>(k + 1); for(int j = 1; j <= k; j++){ cin >> B[i][j] >> S[i][j]; } } for(ll i = 1, a, b, w; i <= m; i++){ cin >> a >> b >> w; sp[a][b] = min(w, sp[a][b]); } for(int k = 1; k <= n; k++){ for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ sp[i][j] = min(sp[i][j], sp[i][k] + sp[k][j]); } } } debug("-------sp----------\n"); for(int i = 1; i <= n; i++){ for(int j =1 ; j <= n; j++){ debug("%lld ",sp[i][j]); } debug("\n"); } ll lo = 0, mi, hi = 1e9; while(lo < hi){ mi = (lo + hi + 1) >> 1; if(pro(mi)) lo = mi; else hi = mi - 1; } cout << lo << '\n'; }

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

merchant.cpp: In function 'bool pro(ll)':
merchant.cpp:19:20: warning: statement has no effect [-Wunused-value]
   19 | #define debug(...) 42
      |                    ^~
merchant.cpp:66:5: note: in expansion of macro 'debug'
   66 |     debug("-------tsp------x = %lld----\n",x);
      |     ^~~~~
merchant.cpp:19:20: warning: statement has no effect [-Wunused-value]
   19 | #define debug(...) 42
      |                    ^~
merchant.cpp:69:13: note: in expansion of macro 'debug'
   69 |             debug("(%lld,%lld) ",tsp[i][j].va,tsp[i][j].vb);
      |             ^~~~~
merchant.cpp:19:20: warning: statement has no effect [-Wunused-value]
   19 | #define debug(...) 42
      |                    ^~
merchant.cpp:71:9: note: in expansion of macro 'debug'
   71 |         debug("\n");
      |         ^~~~~
merchant.cpp: In function 'int main()':
merchant.cpp:19:20: warning: statement has no effect [-Wunused-value]
   19 | #define debug(...) 42
      |                    ^~
merchant.cpp:99:5: note: in expansion of macro 'debug'
   99 |     debug("-------sp----------\n");
      |     ^~~~~
merchant.cpp:19:20: warning: statement has no effect [-Wunused-value]
   19 | #define debug(...) 42
      |                    ^~
merchant.cpp:102:13: note: in expansion of macro 'debug'
  102 |             debug("%lld ",sp[i][j]);
      |             ^~~~~
merchant.cpp:19:20: warning: statement has no effect [-Wunused-value]
   19 | #define debug(...) 42
      |                    ^~
merchant.cpp:104:9: note: in expansion of macro 'debug'
  104 |         debug("\n");
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...