제출 #521267

#제출 시각아이디문제언어결과실행 시간메모리
521267hohohaha여행하는 상인 (APIO17_merchant)C++14
33 / 100
127 ms2476 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 = INT_MAX, big_inf = LLONG_MAX / 1000ll; inline int __mul(int a, int b) { if(!b or a <= big_inf / b) return a * b; } 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) pro[i][j] = -inf; 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]); // cout << i << sp << j << sp << pro[i][j] << endl; } } } 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) { step[i][j] = -big_inf; fori(k, 1, n) { step[i][j] = max(step[i][j], - __mul(ratio, dis[i][k] + dis[k][j]) + pro[i][k]); } } } fori(i, 1, n) fori(j, 1, n) { if(i != j) sum[i][j] = step[i][j]; else sum[i][j] = -big_inf; } 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:105:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  105 |   int mi = lo + hi + 1 >> 1;
      |            ~~~~~~~~^~~
merchant.cpp: In function 'long long int __mul(long long int, long long int)':
merchant.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
   62 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...