제출 #743720

#제출 시각아이디문제언어결과실행 시간메모리
743720grogu여행하는 상인 (APIO17_merchant)C++14
100 / 100
75 ms5400 KiB
#define here cerr<<"===========================================\n" #include <bits/stdc++.h> #define ld double #define ll long long #define ull unsigned long long #define llinf 100000000000000000LL // 10^17 #define iinf 2000000000 // 2*10^9 #define pb push_back #define popb pop_back #define fi first #define sc second #define endl '\n' #define pii pair<int,int> #define pll pair<ll,ll> #define pld pair<ld,ld> #define sz(a) int(a.size()) #define all(a) a.begin(),a.end() #define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;} using namespace std; #define maxn 105 #define maxk 10005 ll n,m,k; ll a[maxn][maxk]; ll b[maxn][maxk]; ll p[maxn][maxk]; ll d[maxn][maxn]; ll c[maxn][maxn]; bool ok(ll x){ for(ll i = 1;i<=n;i++) for(ll j = 1;j<=n;j++) c[i][j] = -(x*min(llinf/x,d[i][j]) - p[i][j]); for(ll f = 1;f<=n;f++) for(ll i = 1;i<=n;i++) for(ll j = 1;j<=n;j++) c[i][j] = max(c[i][j],c[i][f]+c[f][j]); for(ll i = 1;i<=n;i++) if(c[i][i]>=0) return 1; return 0; } ll bs(){ ll l = 1,r = 1000000000,mid,rez; while(l<=r){ mid = (l+r)/2; if(ok(mid)){ l = mid + 1; rez = mid; }else r = mid - 1; } return rez; } int main(){ ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0); cin >> n >> m >> k; for(ll i = 1;i<=n;i++) for(ll j = 1;j<=n;j++) d[i][j] = llinf; //for(ll i = 1;i<=n;i++) d[i][i] = 0; for(ll i = 1;i<=n;i++) for(ll j = 1;j<=k;j++) cin >> a[i][j] >> b[i][j]; for(ll f = 1;f<=k;f++) for(ll i = 1;i<=n;i++) for(ll j = 1;j<=n;j++) if(a[i][f]!=-1&&b[j][f]!=-1) p[i][j] = max(p[i][j],b[j][f]-a[i][f]); for(ll i = 1;i<=m;i++){ ll x,y; cin >> x >> y; cin >> d[x][y]; } for(ll f = 1;f<=n;f++){ for(ll i = 1;i<=n;i++){ for(ll j = 1;j<=n;j++){ d[i][j] = min(d[i][j],d[i][f] + d[f][j]); } } } cout<<bs()<<endl; return 0; }

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

merchant.cpp: In function 'long long int bs()':
merchant.cpp:44:10: warning: 'rez' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |   return rez;
      |          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...