제출 #521272

#제출 시각아이디문제언어결과실행 시간메모리
521272hohohaha여행하는 상인 (APIO17_merchant)C++14
21 / 100
102 ms2112 KiB
// #pragma GCC optimize("Ofast") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") // #pragma GCC optimize("unroll-loops") // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/trie_policy.hpp> // #include <ext/rope> // using namespace __gnu_pbds; // using namespace __gnu_cxx; #include "bits/stdc++.h" using namespace std; #define li long long #define ld long double #define ii pair<int, int> #define vi vector<int> #define vvi vector<vi> #define fi first #define se second #define mp make_pair #define pb push_back #define pf push_front #define eb emplace_back #define em emplace #define ob pop_back #define om pop #define of pop_front #define fori(i, a, b) for(int i = (int) (a); i <= (int) (b); ++i) #define ford(i, a, b) for(int i = (int) (a); i >= (int) (b); --i) #define forIT(it, begin, end) for(__typeof(end) it = (begin) + ((begin) > (end)); it != (end) - ((begin) > (end)); it += 1 - 2 * ((begin) > (end))) #define b_e(x) begin(x), end(x) #define sz(x) ((int)(x).size()) #define bitc __builtin_popcountll mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define rand rng #define endl '\n' #define sp ' ' #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); void solve(); signed main() { // freopen("test.inp","r",stdin); // freopen("test.out","w",stdout); fastio; int tc = 1; fori(test, 1, tc) { solve(); } return 0; } #define int long long const ld pi = 4 * atan(1.0), eps = 1e-9; const int maxn = 105, maxk =1004, inf = 1e15; int n, m, tp; int s[maxn][maxk], b[maxn][maxk]; int dis[maxn][maxn]; int pro[maxn][maxn]; int step[maxn][maxn]; int sum[maxn][maxn]; void solve() { cin >> n >> m >> tp; fori(i, 1, n) { fori(j, 1, n) { if(i == j) dis[i][j] = 0; else dis[i][j] = inf; } } fori(i,1,n) { fori(k, 1, tp) { cin >> b[i][k] >> s[i][k]; } } fori(i, 1, m) { int u, v, w; cin >> u >> v >> w; dis[u][v] = min(dis[u][v], w); } fori(k, 1, n) { fori(i, 1, n) { fori(j, 1, n) { dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]); } } } fori(i, 1, n) { fori(j, 1, n) { fori(k, 1, tp) { if(s[j][k] != -1 and b[i][k] != -1) pro[i][j] = max(pro[i][j], s[j][k] - b[i][k]); } } } int lo = 0; int hi = inf; while(lo < hi) { int mi = lo + hi + 1 >> 1; int ratio = mi; fori(i, 1, n) fori(j, 1, n) { sum[i][j] = -inf; if(i - j and dis[i][j] != inf) sum[i][j] = pro[i][j] - dis[i][j] * ratio; } fori(k, 1, n) fori(i, 1, n) fori(j, 1, n) { sum[i][j] = max(sum[i][j], sum[i][k] + sum[k][j]); } bool ok = 0; fori(i, 1, n) if(sum[i][i] >= 0) ok = 1; if(ok) lo = mi; else hi = mi - 1; } cout << lo; }

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

merchant.cpp: In function 'void solve()':
merchant.cpp:100:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  100 |   int mi = lo + hi + 1 >> 1;
      |            ~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...