제출 #166140

#제출 시각아이디문제언어결과실행 시간메모리
166140imaxblue여행하는 상인 (APIO17_merchant)C++17
0 / 100
154 ms1528 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pb push_back #define x first #define y second #define pii pair<int, int> #define p3i pair<pii, int> #define pll pair<ll, ll> #define p3l pair<pll, ll> #define vi vector<int> #define vpii vector<pii> #define vp3i vector<p3i> #define vpll vector<pll> #define vp3l vector<p3l> #define lseg L, (L+R)/2, N*2+1 #define rseg (L+R)/2+1, R, N*2+2 #define ub upper_bound #define lb lower_bound #define pq priority_queue #define MN 1000000007 #define fox(k, x) for (int k=0; k<x; ++k) #define fox1(k, x) for (int k=1; k<=x; ++k) #define foxr(k, x) for (int k=x-1; k>=0; --k) #define fox1r(k, x) for (int k=x; k>0; --k) #define ms multiset #define flood(x) memset(x, 0x3f3f3f3f, sizeof x) #define drain(x) memset(x, 0, sizeof x) #define rng() ((rand() << 14)+rand()) #define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0) char _; #define pi 3.14159265358979323846 #define startrng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, m, k, a, c, w; int s[105][1005], b[105][1005], best[105][105]; ll path[105][105], dp[105][105][105], path2[105][105]; bool check(int M){ //cout << endl << ' ' << M << ' ' << endl; fox1(l, n){ fox1(l2, n){ path2[l][l2] = best[l][l2] - (path[l][l2]>(1LL<<59)?path[l][l2]:path[l][l2]*M); //cout << path2[l][l2] << ' '; } //cout << endl; } fox1(T, 3) fox1(l, n){ fox1(l2, n){ fox1(l3, n){ path2[l][l2] = max(path2[l][l2], path2[l][l3] + path2[l3][l2]); } } } fox1(l, n){ if (path2[l][l] >= 0) return 1; } return 0; } int32_t main(){ flood(path); scanf("%i%i%i", &n, &m, &k); fox1(l, n){ fox(l2, k){ scanf("%i", &b[l][l2]); if (b[l][l2] == -1) b[l][l2] = (1<<30); } fox(l2, k){ scanf("%i", &s[l][l2]); if (s[l][l2] == -1) s[l][l2] = -(1<<30); } } fox1(l, n){ fox1(l2, n){ best[l][l2] = 0; fox(l3, k){ best[l][l2] = max(best[l][l2], s[l2][l3]-b[l][l3]); } } } fox(l, m){ scanf("%i%i%i", &a, &c, &w); path[a][c] = w; } fox1(T, 3){ fox1(l, n){ fox1(l2, n){ fox1(l3, n){ path[l][l2] = min(path[l][l2], path[l][l3] + path[l3][l2]); } } } } /*fox1(l, n){ fox1(l2, n){ cout << path[l][l2] << ' '; }cout << endl; }*/ int lo = 0, mid, hi = 1000000000; while(lo<hi){ mid=(lo+hi+1)/2; if (check(mid)) lo=mid; else hi=mid-1; } cout << lo; return 0; }

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

merchant.cpp: In function 'int32_t main()':
merchant.cpp:63:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%i%i%i", &n, &m, &k);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:66:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%i", &b[l][l2]);
       ~~~~~^~~~~~~~~~~~~~~~~
merchant.cpp:70:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%i", &s[l][l2]);
       ~~~~~^~~~~~~~~~~~~~~~~
merchant.cpp:83:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i%i", &a, &c, &w);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...