제출 #347750

#제출 시각아이디문제언어결과실행 시간메모리
347750toshtosh여행하는 상인 (APIO17_merchant)C++14
0 / 100
45 ms3436 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int main(){ ll n, m, k, ans = 0; scanf("%lld %lld %lld", &n, &m, &k); ll b[n][k], s[n][k], x, y, z, a[n][n], d[n][n], p[n][n], q[n][n]; for (ll i = 0; i < n; i++){ for (ll j = 0; j < n; j++){ a[i][j] = 0, d[i][j] = 1000000000; } } for (ll i = 0; i < n; i++){ for (ll j = 0; j < k; j++) scanf("%lld %lld", &b[i][j], &s[i][j]); for (ll j = 0; j < i; j++){ for (ll l = 0; l < k; l++){ if (s[j][l] != -1 && b[i][l] != -1) a[i][j] = max(a[i][j], s[j][l] - b[i][l]); if (s[i][l] != -1 && b[j][l] != -1) a[j][i] = max(a[j][i], s[i][l] - b[j][l]); } } } for (ll i = 0; i < m; i++){ scanf("%lld %lld %lld", &x, &y, &z), x--, y--; d[x][y] = z; } for (ll i = 0; i < n; i++){ for (ll j = 0; j < n; j++){ for (ll l = 0; l < n; l++){ d[j][l] = min(d[j][l], d[j][i] + d[i][l]); } } } for (ll i = 0; i < n; i++){ for (ll j = 0; j < n; j++){ p[i][j] = a[i][j], q[i][j] = d[i][j]; } } for (ll i = 0; i < n; i++){ for (ll j = 0; j < n; j++){ for (ll l = 0; l < n; l++){ if (j == i || l == i) continue; ans = max(ans, (a[i][j] + p[j][l] + a[l][i]) / (d[i][j] + q[j][l] + d[l][i])); } } for (ll j = 0; j < n; j++){ for (ll l = 0; l < n; l++){ if (p[j][l] * (q[j][i] + q[i][l]) < (p[j][i] + p[i][l]) * q[j][l]){ p[j][l] = p[j][i] + p[i][l], q[j][l] = q[j][i] + q[i][l]; } } } } printf("%lld\n", ans); }

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

merchant.cpp: In function 'int main()':
merchant.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    6 |  scanf("%lld %lld %lld", &n, &m, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:14:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |   for (ll j = 0; j < k; j++) scanf("%lld %lld", &b[i][j], &s[i][j]);
      |                              ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |   scanf("%lld %lld %lld", &x, &y, &z), x--, y--;
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...