@@ -24,25 +24,6 @@ using namespace std;
2424#define ALL (x ) (x).begin(), (x).end()
2525#define DBG (x ) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
2626
27- #include < ext/pb_ds/assoc_container.hpp>
28- #include < ext/pb_ds/tree_policy.hpp>
29- using namespace __gnu_pbds ;
30-
31- template <class TIn >
32- using indexed_set = tree<
33- TIn, null_type, less<TIn>,
34- rb_tree_tag, tree_order_statistics_node_update>;
35-
36- /*
37- PBDS
38- -------------------------------------------------
39- 1) insert(value)
40- 2) erase(value)
41- 3) order_of_key(value) // 0 based indexing
42- 4) *find_by_order(position) // 0 based indexing
43-
44- */
45-
4627inline void optimizeIO ()
4728{
4829 ios_base::sync_with_stdio (false );
@@ -52,49 +33,37 @@ inline void optimizeIO()
5233const int nmax = 1e3 +7 ;
5334const LL LINF = 1e17 ;
5435
55- string to_str (LL x)
56- {
57- stringstream ss;
58- ss<<x;
59- return ss.str ();
60- }
61-
62- // bool cmp(const PII &A,const PII &B)
63- // {
64- //
65- // }
66-
6736int nodes,edges;
6837
6938vector<PII>adj[nmax];
7039
7140LL MinST (int src = 1 ) /* * n vertices , 1 based indexing **/
7241{
7342 priority_queue< PII,vector<PII>,greater <PII> >PQ;
74- vector<bool > inMinST (nmax, false );
75- vector<PII> parent (nmax,{-1 ,0 });
43+ vector<bool >inMinST (nmax, false );
44+ vector<PII>parent (nmax,{-1 ,0 });
7645 vector<int >min_d (nmax,INF); /* * For maximum spanning tree , USE max_d(nmax,0) **/
7746
78- min_d[src]= 0 ;
47+ min_d[src] = 0 ;
7948 PQ.push ({0 ,src});
8049
8150 while (!PQ.empty ())
8251 {
8352 int now=PQ.top ().S ;
8453 PQ.pop ();
8554
86- inMinST[now]= true ;
55+ inMinST[now] = true ;
8756
8857 for (auto x:adj[now])
8958 {
90- int next= x.F ;
91- int weight= x.S ;
59+ int next = x.F ;
60+ int weight = x.S ;
9261
93- if (inMinST[next]== false && weight< min_d[next]) /* * For maximum spanning tree , weight>max_d[next] **/
62+ if (inMinST[next] == false && weight < min_d[next]) /* * For maximum spanning tree , weight>max_d[next] **/
9463 {
95- min_d[next]= weight;
64+ min_d[next] = weight;
9665 PQ.push (MP (min_d[next],next));
97- parent[next]= MP (now,min_d[next]);
66+ parent[next] = MP (now,min_d[next]);
9867 }
9968 }
10069 }
0 commit comments