제출 #1282386

#제출 시각아이디문제언어결과실행 시간메모리
1282386swishy123여행하는 상인 (APIO17_merchant)C++20
21 / 100
993 ms2160 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double using namespace std; const int def = 1e6+1; const int maxk = 18; const ll inf = 1e18; const ld eps = 1e-9; void solve(){ int n, m, k; cin >> n >> m >> k; vector<vector<ll>> b(n, vector<ll>(k, 0)); auto s = b; for (int i = 0; i < n; i++){ for (int j = 0; j < k; j++) cin >> b[i][j] >> s[i][j]; } vector<vector<ll>> dp1(n, vector<ll>(n, inf)); for (int i = 0; i < m; i++){ ll u, v, w; cin >> u >> v >> w; u--; v--; dp1[u][v] = min(dp1[u][v], w); } for (int k = 0; k < n; k++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) dp1[i][j] = min(dp1[i][j], dp1[i][k] + dp1[k][j]); ll l = 0, r = 1e12, mid = (l + r + 1) / 2; while (l < r){ vector<vector<ll>> dp2(n, vector<ll>(n, inf)); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) for (int u = 0; u < k; u++){ if (dp1[i][j] == inf || i == j) continue; dp2[i][j] = min(dp2[i][j], dp1[i][j] * mid); if (b[i][u] == -1 || s[j][u] == -1) continue; dp2[i][j] = min(dp2[i][j], dp1[i][j] * mid - (s[j][u] - b[i][u])); } for (int k = 0; k < n; k++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) dp2[i][j] = min(dp2[i][j], dp2[i][k] + dp2[k][j]); bool ok = 0; for (int i = 0; i < n; i++){ if (dp2[i][i] <= 0) ok = 1; } if (ok) l = mid; else r = mid - 1; mid = (l + r + 1) / 2; } cout << l; } /* w / dis >= mid mid * dis - w <= 0 100 / 2 >= 1 200 / 4 >= 1 */ main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (ifstream("input.txt").good()){ freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); } int t = 1; while (t--){ solve(); cout << "\n"; } }

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

merchant.cpp:69:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   69 | main(){
      | ^~~~
merchant.cpp: In function 'int main()':
merchant.cpp:74:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:75:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...