Submission #407544

#TimeUsernameProblemLanguageResultExecution timeMemory
407544nguotCommuter Pass (JOI18_commuter_pass)C++14
24 / 100
147 ms19244 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;}) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int l,int r){return l+rng()%(r-l+1);} #define fasty ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define fori(x,a,b) for (int x=a;x<=b;x++) #define ford(x,a,b) for (int x=a;x>=b;x--) #define forv(a,b) for(auto&a:b) #define fi first #define se second #define pb push_back #define ii pair<int,int> #define all(a) a.begin(),a.end() #define reset(f, x) memset(f, x, sizeof(f)) #define getbit(x,i) ((x>>i)&1) #define batbit(x,i) (x|(1ll<<i)) #define tatbit(x,i) (x&~(1<<i)) #define gg exit(0); const int maxn = 2e5 + 10; int n,m,s,t,x,y; vector<ii> ke[maxn]; int f[310][310]; void sub3() { priority_queue<ii,vector<ii>,greater<ii> > h; fori(i,1,n) { fori(j,1,n) f[i][j] = 1e15; f[i][i] = 0; h.push({0,i}); while(!h.empty()) { ii u = h.top(); h.pop(); int umin = u.se,dmin = u.fi; forv(v,ke[umin]) if(f[i][v.fi] > dmin + v.se) { f[i][v.fi] = dmin + v.se; h.push({f[i][v.fi],v.fi}); } } } int kq = 1e15; fori(i,1,n) fori(j,1,n) { if(f[s][i] + f[i][j] + f[j][t]==f[s][t]) kq=min({kq,f[x][i]+f[j][y],f[x][j]+f[i][y]}); } cout<<min(kq,f[x][y]); } main() { //freopen("task.inp","r",stdin); fasty; cin>>n>>m; cin>>s>>t>>x>>y; fori(i,1,m) { int u,v,c;cin>>u>>v>>c; ke[u].pb({v,c}),ke[v].pb({u,c}); } if(n<=300) sub3(); } /* chon 1 dg di ngan nhat tu s->t,cho tat cac canh tren dg di nay = 0 sao cho dg di ngan nhat tu u->v la MIN */ //https://oj.uz/problem/view/JOI18_commuter_pass

Compilation message (stderr)

commuter_pass.cpp:56:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   56 | 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...