Submission #1317063

#TimeUsernameProblemLanguageResultExecution timeMemory
1317063blackscreen1여행하는 상인 (APIO17_merchant)C++20
100 / 100
69 ms2004 KiB
#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; typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset; #define ll long long #define ld long double #define iloop(m, h) for (ll i = m; i != h; i += (m < h ? 1 : -1)) #define jloop(m, h) for (auto j = m; j != h; j += (m < h ? 1 : -1)) #define kloop(m, h) for (auto k = m; k != h; k += (m < h ? 1 : -1)) #define lloop(m, h) for (auto l = m; l != h; l += (m < h ? 1 : -1)) #define iloop_(m, h, g) for (auto i = m; i < h; i += g) #define jloop_(m, h, g) for (auto j = m; j < h; j += g) #define kloop_(m, h, g) for (auto k = m; k < h; k += g) #define lloop_(m, h, g) for (auto l = m; l < h; l += g) #define getchar_unlocked _getchar_nolock // comment before submission #define pll pair<ll, ll> #define plll pair<ll, pll> #define pllll pair<pll, pll> #define vll vector<ll> #define qll queue<ll> #define dll deque<ll> #define pqll priority_queue<ll> #define gll greater<ll> #define INF 100000000000000 #define MOD1 1000000007 #define MOD2 998244353 #define MOD3 1000000009 mt19937 rng(chrono::system_clock::now().time_since_epoch().count()); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n, m, t; cin >> n >> m >> t; ll a[n][t], b[n][t]; iloop(0, n) jloop(0, t) cin >> a[i][j] >> b[i][j]; ll t1, t2, t3; ll dist[n][n]; iloop(0, n) jloop(0, n) dist[i][j] = INF; //iloop(0, n) dist[i][i] = 0; iloop(0, m) { cin >> t1 >> t2 >> t3; t1--, t2--; dist[t1][t2] = min(dist[t1][t2], t3); } kloop(0, n) iloop(0, n) jloop(0, n) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]); //iloop(0, n) {jloop(0, n) {cout << dist[i][j] << " ";} cout << "\n";} //cout << "\n"; ll opb[n][n]; iloop(0, n) jloop(0, n) opb[i][j] = 0; iloop(0, n) jloop(0, n) kloop(0, t) if (a[i][k] != -1 && b[j][k] != -1) opb[i][j] = max(opb[i][j], b[j][k] - a[i][k]); ll lb = 0, ub = 1e9, mid, adj[n][n]; while (lb < ub) { mid = (lb + ub + 1) >> 1; iloop(0, n) jloop(0, n) adj[i][j] = INF; iloop(0, n) jloop(0, n) adj[i][j] = min(dist[i][j], INF / mid) * mid - opb[i][j]; //cout << mid << ":\n"; //iloop(0, n) {jloop(0, n) {cout << adj[i][j] << " ";} cout << "\n";} //cout << "\n"; kloop(0, n) iloop(0, n) jloop(0, n) adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]); bool can = 0; iloop(0, n) if (adj[i][i] <= 0) {can = 1; break;} if (can) lb = mid; else ub = mid - 1; } cout << lb; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...