제출 #774373

#제출 시각아이디문제언어결과실행 시간메모리
774373vjudge1여행하는 상인 (APIO17_merchant)C++17
0 / 100
2 ms340 KiB
#include <bits/stdc++.h> #define ve vector #define vi vector<int> #define vii vector<ii> #define ii pair<int,int> #define fi first #define se second #define ll long long #define INF 1e18+7 #define pb push_back #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) using namespace std; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int MOD = 1e9+7; const int nax = 100+5; const int kax = 1005; void readio(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } ll b[nax][kax], s[nax][kax], go[nax], to[nax]; ve<pair<int,ll>> adj[nax]; short vis[nax]; ll dfs(int u, ll dep){ vis[u] = 1; //cout << u << endl; for(auto x : adj[u]){ if(vis[x.fi] == 1 && x.fi == 0){ to[u] = min(to[u], x.se); } if(!vis[x.fi]){ dfs(x.fi, dep+x.se); } to[u] = min(to[x.fi]+x.se, to[u]); go[x.fi] = min(dep + x.se, go[x.fi]); } vis[u] = 2; return to[u]; } int main() { readio(); optimise; int n,m,k; cin >> n >> m >> k; for (int i = 0; i < n; ++i) { go[i] = to[i] = INF; for (int j = 0; j < k; ++j) { cin >> b[i][j] >> s[i][j]; } } for (int i = 0; i < m; ++i) { int a,b,c; cin >> a >> b >> c; a--,b--; adj[a].pb({b,c}); } go[0] = 0; dfs(0,0); ll ans = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < k; ++j) { if(b[0][j] != -1 && s[i][j] != -1){ ans = max(ans, (s[i][j]-b[0][j])/(to[i]+go[i])); } } } cout << ans << endl; }

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

merchant.cpp: In function 'void readio()':
merchant.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
merchant.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...