제출 #444401

#제출 시각아이디문제언어결과실행 시간메모리
444401mjhmjh1104Travelling Merchant (APIO17_merchant)C++17
0 / 100
67 ms1356 KiB
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int n, m, k, b[106][1006], s[106][1006]; long long dist[106][106], c[106][106], cost[106][106]; int main() { scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < n; i++) for (int j = 0; j < k; j++) scanf("%d%d", b[i] + j, s[i] + j); fill(dist[0], dist[105] + 106, (long long)4e18); for (int i = 0; i < m; i++) { int u, v, w; scanf("%d%d%d", &u, &v, &w); u--, v--; dist[u][v] = w; } for (int i = 0; i < 106; i++) dist[i][i] = 0; for (int k = 0; k < n; k++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { int curr = 0; for (int l = 0; l < k; l++) if (b[i][l] != -1 && s[j][l] != -1) curr = max(curr, s[j][l] - b[i][l]); c[i][j] = curr; } int l = 0, r = 1e9; while (l < r) { int m = (l + r) / 2; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cost[i][j] = m * dist[i][j] - c[i][j]; for (int k = 0; k < n; k++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]); for (int i = 0; i < n; i++) if (cost[i][i] < 0) { l = m + 1; goto next; } r = m; next:; } printf("%d", l); }

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

merchant.cpp: In function 'int main()':
merchant.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d%d%d", &n, &m, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:11:66: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for (int i = 0; i < n; i++) for (int j = 0; j < k; j++) scanf("%d%d", b[i] + j, s[i] + j);
      |                                                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d%d%d", &u, &v, &w);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...