Submission #3856125
Source Code Expand
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <queue> #include <deque> #include <list> #include <map> #include <set> #include <cmath> #include <cstring> #include <string> #include <bitset> #include <fstream> #include <iomanip> using namespace std; typedef long long ll; typedef long double db; typedef vector<int> vi; typedef vector<long long> vll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<double,double> pdd; typedef vector<pii> vii; #define INF 10000000000000007ll #define pb push_back #define mp make_pair #define err(x) cout<<#x<<"= "<<x<<endl; #define rep(i,n) for(int i =0; i< n; i++) #define ff first #define ss second #define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) ) #define SIZE 100010 #define eps 1e-13 set<pll > llist[SIZE]; int n,m,s,t; ll dist[SIZE],dis2[SIZE],nxt[SIZE]; priority_queue<pll, vector<pll >, greater<pll > > pq; int main(){ // #ifdef ONLINE_JUDGE // freopen("little.in", "r" , stdin); // freopen("little.out", "w", stdout); // cin.tie(false); cout.tie(false); // #endif ios::sync_with_stdio(false); cin>>n>>m>>s>>t;s--;t--; rep(i,m){ ll a,b,c; cin>>a>>b>>c;a--;b--; llist[a].insert(mp(b,c)); llist[b].insert(mp(a,c)); } rep(i,n) dist[i]= dis2[i] = INF,nxt[i] =-1; pq.push(mp(0,t));dist[t] = 0;dis2[t] = 0; while(!pq.empty()){ pll top = pq.top();pq.pop(); if(dist[top.ss] !=top.ff && dis2[top.ss] != top.ff) continue; // cout<<endl; // cout<<top.ss << "is fixed at dist of "<<top.ff<<endl; for( pll x: llist[top.ss]){ if(dist[x.ff] > top.ff + x.ss ){ swap(dist[x.ff], dis2[x.ff]); dist[x.ff] = top.ff + x.ss; pq.push(mp(dist[x.ff], x.ff)); nxt[x.ff] = top.ss; } else if(dis2[x.ff] > top.ff + x.ss&& nxt[top.ss] != x.ff){ dis2[x.ff] = top.ff+ x.ss; pq.push(mp(dis2[x.ff], x.ff)); // cout<<x.ff<<" is fixing2 at "<<top.ff + x.ss<<endl; } else if(dis2[x.ff] > dis2[top.ss] + x.ss && nxt[top.ss] == x.ff){ dis2[x.ff] = dis2[top.ss] + x.ss; pq.push(mp(dis2[x.ff],x.ff)); // cout<<x.ff<<" is fixing2 at "<<dis2[x.ff]<<endl; } } } // rep(i,n)cout<<dist[i]<<' '<<dis2[i]<<endl; ll ans = dis2[s],now= s; if(ans == INF){ cout<<-1<<endl; return 0; } while(now!=t){ ll nxt =-1,cur = INF; for(pll x: llist[now]) if(cur> dis2[x.ff] + x.ss) cur = dis2[x.ff] +x.ss,nxt = x.ff; now = nxt; ans = max(ans , cur); } cout<<ans<<endl; return 0; };
Submission Info
Submission Time | |
---|---|
Task | D - Revenge of the Broken Door |
User | Dipak |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2549 Byte |
Status | WA |
Exec Time | 10504 ms |
Memory | 35320 KB |
Judge Result
Set Name | All | ||||||
---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 100 | ||||||
Status |
|
Set Name | Test Cases |
---|---|
All | 00_sample_00, 00_sample_01, 00_sample_02, 10_small_0, 10_small_1, 10_small_2, 10_small_3, 10_small_4, 10_small_5, 10_small_6, 10_small_7, 10_small_8, 10_small_9, 20_med_0, 20_med_1, 20_med_2, 20_med_3, 20_med_4, 20_med_5, 20_med_6, 21_med_0, 21_med_1, 21_med_2, 30_large_0, 30_large_1, 30_large_2, 30_large_3, 30_large_4, 30_large_5, 30_large_6, 31_large_0, 31_large_1, 31_large_2, 40_circle_0, 40_circle_1, 40_circle_2, 40_circle_3, 40_circle_4, 41_impossible_0, 41_impossible_1, 41_impossible_2, 42_special_0, 42_special_1, 42_special_10, 42_special_11, 42_special_12, 42_special_13, 42_special_14, 42_special_2, 42_special_3, 42_special_4, 42_special_5, 42_special_6, 42_special_7, 42_special_8, 42_special_9, 43_special_0, 43_special_1, 43_special_2, 43_special_3, 43_special_4, 43_special_5, 43_special_6, 43_special_7, 43_special_8, 43_special_9 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00 | AC | 3 ms | 5248 KB |
00_sample_01 | AC | 3 ms | 5248 KB |
00_sample_02 | AC | 3 ms | 5248 KB |
10_small_0 | AC | 3 ms | 5248 KB |
10_small_1 | AC | 3 ms | 5248 KB |
10_small_2 | AC | 3 ms | 5248 KB |
10_small_3 | AC | 3 ms | 5248 KB |
10_small_4 | WA | 3 ms | 5248 KB |
10_small_5 | AC | 3 ms | 5248 KB |
10_small_6 | AC | 3 ms | 5248 KB |
10_small_7 | AC | 3 ms | 5248 KB |
10_small_8 | AC | 3 ms | 5248 KB |
10_small_9 | AC | 3 ms | 5248 KB |
20_med_0 | TLE | 10504 ms | 20216 KB |
20_med_1 | WA | 5 ms | 5760 KB |
20_med_2 | TLE | 10503 ms | 13820 KB |
20_med_3 | TLE | 10503 ms | 18296 KB |
20_med_4 | TLE | 10504 ms | 20604 KB |
20_med_5 | TLE | 10503 ms | 21364 KB |
20_med_6 | TLE | 10504 ms | 15352 KB |
21_med_0 | TLE | 10503 ms | 13564 KB |
21_med_1 | TLE | 10504 ms | 21620 KB |
21_med_2 | TLE | 10504 ms | 22264 KB |
30_large_0 | TLE | 10504 ms | 21240 KB |
30_large_1 | TLE | 10503 ms | 11132 KB |
30_large_2 | TLE | 10504 ms | 14968 KB |
30_large_3 | TLE | 10504 ms | 21500 KB |
30_large_4 | TLE | 10504 ms | 16504 KB |
30_large_5 | TLE | 10503 ms | 20600 KB |
30_large_6 | TLE | 10503 ms | 21880 KB |
31_large_0 | TLE | 10504 ms | 17144 KB |
31_large_1 | TLE | 10503 ms | 22272 KB |
31_large_2 | TLE | 10504 ms | 21244 KB |
40_circle_0 | TLE | 10504 ms | 21888 KB |
40_circle_1 | TLE | 10504 ms | 21888 KB |
40_circle_2 | TLE | 10504 ms | 21888 KB |
40_circle_3 | TLE | 10503 ms | 21888 KB |
40_circle_4 | TLE | 10503 ms | 21888 KB |
41_impossible_0 | TLE | 10504 ms | 35320 KB |
41_impossible_1 | TLE | 10504 ms | 35320 KB |
41_impossible_2 | TLE | 10504 ms | 35320 KB |
42_special_0 | TLE | 10503 ms | 21888 KB |
42_special_1 | TLE | 10504 ms | 21888 KB |
42_special_10 | TLE | 10504 ms | 22272 KB |
42_special_11 | TLE | 10503 ms | 22656 KB |
42_special_12 | TLE | 10504 ms | 23456 KB |
42_special_13 | TLE | 10504 ms | 24824 KB |
42_special_14 | TLE | 10504 ms | 27632 KB |
42_special_2 | TLE | 10503 ms | 21888 KB |
42_special_3 | TLE | 10504 ms | 21888 KB |
42_special_4 | TLE | 10504 ms | 21888 KB |
42_special_5 | TLE | 10504 ms | 21888 KB |
42_special_6 | TLE | 10503 ms | 21888 KB |
42_special_7 | TLE | 10503 ms | 21888 KB |
42_special_8 | TLE | 10504 ms | 22016 KB |
42_special_9 | TLE | 10503 ms | 22144 KB |
43_special_0 | TLE | 10504 ms | 23040 KB |
43_special_1 | TLE | 10504 ms | 23040 KB |
43_special_2 | TLE | 10504 ms | 23188 KB |
43_special_3 | TLE | 10503 ms | 23040 KB |
43_special_4 | TLE | 10503 ms | 23040 KB |
43_special_5 | TLE | 10504 ms | 23104 KB |
43_special_6 | TLE | 10503 ms | 23040 KB |
43_special_7 | TLE | 10504 ms | 23040 KB |
43_special_8 | TLE | 10504 ms | 23040 KB |
43_special_9 | TLE | 10504 ms | 23040 KB |