#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef unsigned long long ull;
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;
typedef long long ll;
typedef double db;
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
const int inf = 1e9, maxn = 2e5 + 48, mod = 998244353, N = 112;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 300;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = acos(-1);
const ll INF = 1e18;
int v, u, w;
int n, m, k, b[N][N], s[N][N], d[N][N], c[N][N], dp[N][N][N << 2];
main () {
scanf("%lld%lld%lld", &n, &m, &k);
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= k; ++j)
scanf("%lld%lld", &b[i][j], &s[i][j]);
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
if (i != j)
d[i][j] = INF;
while (m--) {
scanf("%lld%lld%lld", &v, &u, &w);
d[v][u] = min(d[v][u], w);
}
for (int k = 1; k <= n; ++k)
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
if (d[i][k] < INF && d[k][j] < INF)
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
for (int x = 1; x <= k; ++x)
if (b[i][x] != -1 && s[j][x] != -1)
c[i][j] = max(c[i][j], s[j][x] - b[i][x]);
for (int x = 0; x <= n*8; ++x)
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
dp[i][j][x] = -INF;
for (int i = 1; i <= n; ++i)
dp[i][i][0] = 0;
for (int x = 0; x <= n*8; ++x)
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
if (dp[i][j][x] != -INF)
for (int k = 1; k <= n; ++k)
if (j != k && x + d[j][k] <= n + n)
dp[i][k][x + d[j][k]] = max(dp[i][k][x + d[j][k]], dp[i][j][x] + c[j][k]);
int ans = 0;
for (int x = 0; x <= n*8; ++x)
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
if (i != j)
ans = ma+x(ans, (dp[i][j][x] + c[j][i]) / (x + d[j][i]));
cout << ans << endl;
}
Compilation message
merchant.cpp:47:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
47 | main () {
| ^
merchant.cpp: In function 'int main()':
merchant.cpp:99:12: error: 'ma' was not declared in this scope; did you mean 'm'?
99 | ans = ma+x(ans, (dp[i][j][x] + c[j][i]) / (x + d[j][i]));
| ^~
| m
merchant.cpp:99:61: error: 'x' cannot be used as a function
99 | ans = ma+x(ans, (dp[i][j][x] + c[j][i]) / (x + d[j][i]));
| ^
merchant.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
48 | scanf("%lld%lld%lld", &n, &m, &k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:51:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
51 | scanf("%lld%lld", &b[i][j], &s[i][j]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:60:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
60 | scanf("%lld%lld%lld", &v, &u, &w);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~