제출 #333751

#제출 시각아이디문제언어결과실행 시간메모리
333751NhatMinh0208여행하는 상인 (APIO17_merchant)C++14
100 / 100
287 ms5100 KiB
/* Normie's Template v2.0 */ // Standard library in one include. #include <bits/stdc++.h> using namespace std; // ordered_set library. #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set(el) tree<el,null_type,less<el>,rb_tree_tag,tree_order_statistics_node_update> // AtCoder library. (Comment out these two lines if you're not submitting in AtCoder.) (Or if you want to use it in other judges, run expander.py first.) //#include <atcoder/all> //using namespace atcoder; //Pragmas (Comment out these three lines if you're submitting in szkopul.) #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //File I/O. #define FILE_IN "cseq.inp" #define FILE_OUT "cseq.out" #define ofile freopen(FILE_IN,"r",stdin);freopen(FILE_OUT,"w",stdout) //Fast I/O. #define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define nfio cin.tie(0);cout.tie(0) #define endl "\n" //Order checking. #define ord(a,b,c) ((a>=b)and(b>=c)) //min/max redefines, so i dont have to resolve annoying compile errors. #define min(a,b) (((a)<(b))?(a):(b)) #define max(a,b) (((a)>(b))?(a):(b)) //Constants. #define MOD (ll(998244353)) #define MAX 300001 #define mag 320 //Pairs and 3-pairs. #define p1 first #define p2 second.first #define p3 second.second #define fi first #define se second #define pii(element_type) pair<element_type,element_type> #define piii(element_type) pair<element_type,pii(element_type)> //Quick power of 2. #define pow2(x) (ll(1)<<x) //Short for-loops. #define ff(i,__,___) for(int i=__;i<=___;i++) #define rr(i,__,___) for(int i=__;i>=___;i--) //Typedefs. #define bi BigInt typedef long long ll; typedef long double ld; typedef short sh; //---------END-------// vector<piii(ll)> gt[101]; ll b[101][1001],s[101][1001]; ll dis[101][101]; ld cur[101]; ll eu[10001],ew[10001],ev[10001]; ll n,m,i,j,k,t,t1,u,v,a; ll check(ll mul) { // cout<<"\ncheck "<<mul<<endl; for (ll i=1;i<=n;i++) cur[i]=9e18; cur[1]=0; for (ll cnt=0;cnt<2*n;cnt++) { u=0; for (ll i=1;i<=n;i++) { for (piii(ll) g : gt[i]) { // cout<<"relax "<<i<<' '<<g.fi<<' '<<cur[i]<<' '<<cur[g.fi]<<' '<<(ld)cur[i]-g.se.fi-(1e-9)+g.se.se*mul<<endl; if (cur[g.fi]>(ld)cur[i]-g.se.fi-(1e-9)+g.se.se*mul) { cur[g.fi]=(ld)cur[i]-g.se.fi-(1e-9)+g.se.se*mul; u=1; } } } // cout<<cnt<<endl; // for (ll i=0;i<n;i++) cout<<cur[i]<<' '; if (!u) return 0; } return 1; } ll bs(ll l, ll r) { ll mid=(l+r)/2+1; if (l==r) return l; if (check(mid)) return bs(mid,r); else return bs(l,mid-1); } int main() { fio; cin>>n>>m>>t; for (i=1;i<=n;i++) { for (j=1;j<=t;j++) { cin>>b[i][j]>>s[i][j]; } for (j=1;j<=n;j++) { dis[i][j]=2e9; } dis[i][i]=0; } for (i=1;i<=m;i++) { cin>>eu[i]>>ev[i]>>ew[i]; dis[eu[i]][ev[i]]=min(dis[eu[i]][ev[i]],ew[i]); gt[eu[i]].push_back({ev[i],{0,ew[i]}}); //cout<<eu[i]<<' '<<ev[i]<<' '<<0<<' '<<ew[i]<<endl; } for (k=1;k<=n;k++) for (i=1;i<=n;i++) for (j=1;j<=n;j++) { dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]); } for (i=1;i<=n;i++) for (j=1;j<=n;j++) if (dis[i][j]!=2e9) { u=-2e9-7; for (k=1;k<=t;k++) if ((b[i][k]!=-1)and(s[j][k]!=-1)) u=max(u,s[j][k]-b[i][k]); if (u>0) gt[i].push_back({j,{u,dis[i][j]}}); //if (u>0) cout<<i<<' '<<j<<' '<<u<<' '<<dis[i][j]<<endl; } cout<<bs(0,1e9); }

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

merchant.cpp:20: warning: ignoring #pragma comment  [-Wunknown-pragmas]
   20 | #pragma comment(linker, "/stack:200000000")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...