제출 #775153

#제출 시각아이디문제언어결과실행 시간메모리
775153gagik_2007Travelling Merchant (APIO17_merchant)C++17
0 / 100
13 ms2096 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define ff first #define ss second ll ttt; const ll INF=1e18; const ll MOD=1e9+7; const ll N=107; const ll K=1007; ll n,m,k; vector<int>g[N],rg[N]; vector<int>order; bool tsused[N]; bool sccused[N]; vector<int>comp[N]; int compind[N]; ll b[K][N],s[K][N]; ll maxval[N]; void tsdfs(int v){ tsused[v]=true; for(int to:g[v]){ if(!tsused[to]){ tsdfs(to); } } order.push_back(v); } void topsort(){ for(int v=1;v<=n;v++){ if(!tsused[v]){ tsdfs(v); } } reverse(order.begin(),order.end()); } void sccdfs(int c, int v){ comp[c].push_back(v); compind[v]=c; sccused[v]=true; for(int to:g[v]){ if(!sccused[to]){ sccdfs(c,to); } } } void SCC(){ topsort(); for(int v=1;v<=n;v++){ for(int to:g[v]){ rg[to].push_back(v); } } int cur=1; for(int v=1;v<=n;v++){ if(!sccused[v]){ sccdfs(cur,v); cur++; } } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); freopen("output.txt","w",stdout); cin>>n>>m>>k; for(int i=1;i<=n;i++){ for(int j=1;j<=k;j++){ cin>>b[i][j]>>s[i][j]; } } for(int i=0;i<m;i++){ int x,y; cin>>x>>y; g[x].push_back(y); } SCC(); ll ans=0; for(int i=1;i<=k;i++){ for(int v=1;v<=n;v++){ if(compind[v]==compind[1]){ maxval[i]=max(maxval[i],s[v][i]); } } ans=max(ans,b[1][i]-maxval[i]); } cout<<ans<<endl; }

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

merchant.cpp: In function 'int main()':
merchant.cpp:77:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |     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...