제출 #200293

#제출 시각아이디문제언어결과실행 시간메모리
200293dimash241여행하는 상인 (APIO17_merchant)C++17
100 / 100
124 ms4600 KiB
#pragma GCC target("avx2") #pragma GCC optimize("O3") # include <x86intrin.h> # include <bits/stdc++.h> # include <ext/pb_ds/assoc_container.hpp> # include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define _USE_MATH_DEFINES_ #define ll long long #define ld long double #define Accepted 0 #define pb push_back #define mp make_pair #define sz(x) (int)(x.size()) #define every(x) x.begin(),x.end() #define F first #define S second #define lb lower_bound #define ub upper_bound #define For(i,x,y) for (ll i = x; i <= y; i ++) #define FOr(i,x,y) for (ll i = x; i >= y; i --) #define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) // ROAD to... Red inline void Input_Output () { //freopen(".in", "r", stdin); //freopen(".out", "w", stdout); } const double eps = 0.000001; const ld pi = acos(-1); const int maxn = 1e7 + 9; const int mod = 1e9 + 7; const ll MOD = 1e18 + 9; const ll INF = 1e18 + 123; const int inf = 1e9 + 11; const int mxn = 1e6 + 9; const int N = 6e5 + 123; const int M = 22; const int pri = 997; const int Magic = 2101; #define int long long const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1}; int n, m, k; int b[152][1052]; int s[152][1052]; int dist[152][152]; int cost[152][152]; int nw[152]; vector < int > g[145]; int dp[152][152]; main () { SpeedForce; cin >> n >> m >> k; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= k; ++j) cin >> b[i][j] >> s[i][j]; } for (int i = 1; i <= n; i ++) for (int j = 1; j <= n; j ++) dist[i][j] = inf; for (int i = 1; i <= m; i ++) { int x, y, z; cin >> x >> y >> z; dist[x][y] = z; } for (int k = 1; k <= n; k ++) { for (int i = 1; i <= n; i ++) { for (int j = 1; j <= n; j ++) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); } } for (int i = 1; i <= n; i ++) { for (int j = 1; j <= n; j ++) { for (int it = 1; it <= k; ++it) { if (s[j][it] != -1 && b[i][it] != -1) cost[i][j] = max(cost[i][j], s[j][it] - b[i][it]); } } } int l = 0, r = 1e9 + 1; while (l + 1 < r) { int md = (l + r) >> 1; for (int i = 1; i <= n; i ++) { for (int j = 1; j <= n; j ++) { dp[i][j] = cost[i][j] - dist[i][j] * (ll)md; } } for (int k = 1; k <= n; k++) for (int i = 1; i <= n; i ++) { for (int j = 1; j <= n; j ++) { dp[i][j] = max(dp[i][j], dp[i][k] + dp[k][j]); } } bool good = 0; for (int i = 1; i <= n; i ++) if(dp[i][i] >= 0) good = 1; if(good) l = md; else r = md; } cout << l << '\n'; return Accepted; } // B...a

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

merchant.cpp:62:8: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  main () {
        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...