제출 #95763

#제출 시각아이디문제언어결과실행 시간메모리
95763Bodo171여행하는 상인 (APIO17_merchant)C++14
0 / 100
1073 ms19424 KiB
#include <iostream> #include <fstream> #include <queue> #include <climits> #define mp make_pair using namespace std; const int nmax=105; const int kmax=1005; queue< pair<int,int> > q; vector<int> v[nmax]; vector<long long> cost[nmax]; long long d[nmax][kmax],prof[nmax][kmax],pret[nmax][kmax]; int viz[nmax][kmax]; int n,k,m,nod,item,nxt,i,j,a,b,c; long long p,ans; bool check(long long x) { while(!q.empty()) q.pop(); q.push({0,0}); for(int i=0;i<=n;i++) for(int j=0;j<=k;j++) viz[i][j]=0; for(int i=1;i<=n;i++) for(int j=0;j<=k;j++) d[i][j]=LLONG_MIN; while(!q.empty()) { nod=q.front().first;item=q.front().second; q.pop(); viz[nod][item]++; if(viz[nod][item]>=n*k+1) return 1; for(int i=0;i<v[nod].size();i++) { if(d[nod][item]-1LL*x*cost[nod][i]>=d[v[nod][i]][item]) { d[v[nod][i]][item]=d[nod][item]-1LL*x*cost[nod][i]; q.push(mp(v[nod][i],item)); } nxt=v[nod][i]; if(item) { if(d[nod][item]+1LL*prof[nxt][item]-1LL*x*cost[nod][i]>=d[nxt][0]&&prof[nxt][item]!=-1) { d[nxt][0]=d[nod][item]-1LL*x*cost[nod][i]+1LL*prof[nxt][item]; q.push({nxt,0}); } } } if(!item) { for(int i=1;i<=k;i++) if(d[nod][0]-1LL*pret[nod][i]>=d[nod][i]&&pret[nod][i]!=-1) { d[nod][i]=d[nod][0]-1LL*pret[nod][i]; q.push({nod,i}); } } } return 0; } int main() { //freopen("data.in","r",stdin); ios_base::sync_with_stdio(false); cin>>n>>m>>k; for(i=1;i<=n;i++) { pret[i][0]=-1,prof[i][0]=-1; for(j=1;j<=k;j++) { cin>>pret[i][j]; cin>>prof[i][j]; } } for(i=1;i<=n;i++) v[0].push_back(i),cost[0].push_back(0); for(i=1;i<=k;i++) pret[0][i]=prof[0][i]=-1; for(i=1;i<=m;i++) { cin>>a>>b>>c; v[a].push_back(b); cost[a].push_back(c); } for(p=30;p>=0;p--) if(check(ans+(1LL<<p))) ans+=(1LL<<p); cout<<ans; return 0; }

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

merchant.cpp: In function 'bool check(long long int)':
merchant.cpp:32:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<v[nod].size();i++)
                     ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...