Submission #1020917

#TimeUsernameProblemLanguageResultExecution timeMemory
1020917modwweCommuter Pass (JOI18_commuter_pass)C++17
100 / 100
305 ms26348 KiB
//https://www.instagram.com/_modwwe/ #pragma GCC optimize("Ofast,unroll-loops") //#pragma GCC target("avx2,bmi,bmi2") #include<bits/stdc++.h> #define int long long //#define ll long long #define down cout<<'\n'; #define debug cout<<" cucuucucuuu",down #define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".out","w",stdout) #define pb push_back #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; void phongbeo(); const int inf=1e18; const int mod2=1e9+7; const int mod1=998244353; struct icd { int a,b; }; struct ib { int a; int b; }; struct ic { int a,b,c; }; struct id { int a,b,c,d; }; struct ie { int a,b,c, d,e,f; }; int n,m,s1,s2,s4,s3,sf,k,r,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,l,l2,r2; int i,s10,s12; int el=29; main() { #ifndef ONLINE_JUDGE // fin(task),fou(task); #endif NHP /// cin>>s1; // modwwe phongbeo(); } struct cmp { bool operator()(ib a,ib b) { return a.a>b.a ; } }; struct cmp2 { bool operator()(ic a,ic b) { return a.a>b.a; } }; priority_queue<ib,vector<ib>,cmp>p; int a[100001][3] ; bool b[100001] ; bool c[100001][4] ; vector<ib> v[100001]; priority_queue<ic,vector<ic>,cmp2>pp; void dis(int f,int y) { p.push({0,f}); for(int i=1;i<=n;i++) b[i]=0; while(!p.empty()) { ib x=p.top(); p.pop(); if(b[x.b])continue; a[x.b][y]=x.a; b[x.b]=1; for(auto f:v[x.b]) if(!b[f.b]) p.push({f.a+x.a,f.b}); } } void phongbeo() { cin>>n>>m; cin>>l>>r; cin>>l2>>r2; for(int i=1;i<=m;i++) cin>>s2>>s3>>s4,v[s2].pb({s4,s3}),v[s3].pb({s4,s2}); dis(l,0); dis(r,1); dis(r2,2); pp.push({0,l2,0}); s4=inf; while(!pp.empty()) { ic x=pp.top(); pp.pop(); // cout<<x.a+a[x.b][2]<<" "<<a[x.b][2]<<" "<<x.a<<" "<<x.b,debug if(c[x.b][x.c]) continue ; s4=min(s4,x.a+a[x.b][2]); c[x.b][x.c]=1; if(x.c==0){ for(auto f:v[x.b]) if(!c[f.b][x.c]) pp.push({f.a+x.a,f.b,x.c}); if(!c[x.b][1]&&a[x.b][0]+a[x.b][1]==a[r][0])pp.push({x.a,x.b,1}); } else if(x.c==1) { for(auto f:v[x.b]) if(!c[f.b][x.c]&&a[f.b][0]+a[f.b][1]==a[r][0]){ if(a[x.b][0]+a[f.b][1]+f.a==a[r][0]) pp.push({x.a,f.b,3}); if(a[f.b][0]+a[x.b][1]+f.a==a[r][0])pp.push({x.a,f.b,2}); } } else { for(auto f:v[x.b]) if(!c[f.b][x.c]&&a[f.b][0]+a[f.b][1]==a[r][0]){ if(a[x.b][0]+a[f.b][1]+f.a==a[r][0]&&x.c==3) pp.push({x.a,f.b,3}); if(a[f.b][0]+a[x.b][1]+f.a==a[r][0]&&x.c==2)pp.push({x.a,f.b,2}); } } } cout<<s4; }

Compilation message (stderr)

commuter_pass.cpp:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...