"Hdoj" 2388 Playground Hideout

Source: Internet
Author: User

Priority Queue Direct AC.

1 /*2388*/2#include <iostream>3#include <sstream>4#include <string>5#include <map>6#include <queue>7#include <Set>8#include <stack>9#include <vector>Ten#include <deque> One#include <algorithm> A#include <cstdio> -#include <cmath> -#include <ctime> the#include <cstring> -#include <climits> -#include <cctype> -#include <cassert> +#include <functional> -#include <iterator> +#include <iomanip> A using namespacestd; at //#pragma COMMENT (linker, "/stack:102400000,1024000") -  - #defineSTI set<int> - #defineStpii Set<pair<int, int> > - #defineMpii map<int,int> - #defineVI vector<int> in #definePII pair<int,int> - #defineVpii vector<pair<int,int> > to #defineRep (I, A, n) for (int i=a;i<n;++i) + #definePer (i, a, n) for (int i=n-1;i>=a;--i) - #defineCLR Clear the #definePB Push_back * #defineMP Make_pair $ #defineFIR FirstPanax Notoginseng #defineSEC Second - #defineAll (x) (x). Begin (), (x). End () the #defineSZ (x) ((int) (x). Size ()) + #defineLson L, Mid, rt<<1 A #defineRson mid+1, R, rt<<1|1 the  +typedefstructnode_t { -     intu, W; $      $ node_t () {} -node_t (intUintW): - u (U), W (w) {} the      -FriendBOOL operator< (Constnode_t& A,Constnode_t&b) {Wuyi         returnA.W >B.W; the     } -      Wu } node_t; -  Abouttypedefstruct { $     intV, W, NXT; - } edge_t; -  - Const intINF =0x3f3f3f3f; A Const intMAXV = 1e5+5; + Const intMaxe = 2e5+5; the edge_t E[maxe]; - intHEAD[MAXV], l; $ intW[MAXV]; the intDIS[MAXV]; the BOOLVISIT[MAXV]; the intN, M; the  - voidinit () { inMemset (Head,-1,sizeof(head)); theL =0; the } About  the voidAddedge (intUintVintWaintWB) { theE[L].V =v; theE[L].W =wa; +E[L].NXT =Head[u]; -Head[u] = l++; the     BayiE[L].V =u; theE[L].W =WB; theE[L].NXT =Head[v]; -HEAD[V] = l++; - } the  the intBFs () { thePriority_queue<node_t>Q; the node_t nd; -     intu, V, W; the      the     //memset (DIS, INF, sizeof (DIS)); thememset (Visit,false,sizeof(visit));94Rep (I,0, N) { the Q.push (node_t (i, w[i])); theDis[i] =W[i]; the     }98      About      while(!Q.empty ()) { -nd =q.top ();101 Q.pop ();102         if(visit[nd.u])103             Continue;104VISIT[U=ND.U] =true; the          for(intK=head[u]; k!=-1; k=e[k].nxt) {106v =e[k].v;107             if(Dis[v] > dis[u]+E[K].W) {108DIS[V] = Dis[u] +E[K].W;109 Q.push (node_t (V, Dis[v])); the             }111         } the     }113      the     intRET =0; theRep (I,1, N) the         if(Dis[i] >Dis[ret])117RET =i;118         119     returnret; - }121 122 voidsolve () {123     intAns =BFS ();124      theprintf"%d\n\n", ans);126 }127  - intMain () {129Ios::sync_with_stdio (false); the #ifndef Online_judge131Freopen ("data.in","R", stdin); theFreopen ("Data.out","W", stdout);133     #endif134     135     intT;136     intu, V, WA, WB;137     138scanf"%d", &t);139Rep (TT,1, t+1) { $scanf"%d%d", &n, &m);141 init ();142Rep (I,0, N)143scanf"%d", &w[i]);144Rep (I,0, M) {145scanf"%d %d%d%d", &u, &v, &wa, &WB);146 Addedge (U, V, WA, WB);147         }148printf"Scenario #%d:\n", TT);149 solve (); Max     }151      the #ifndef Online_judge153printf"Time =%d.\n", (int) clock ());154     #endif155     156     return 0;157}

"Hdoj" 2388 Playground Hideout

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.