Skip to content

Commit efd2e39

Browse files
committed
some modification
1 parent ba75f25 commit efd2e39

8 files changed

+42
-188
lines changed

Diff for: .vscode/c_cpp_properties.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Win32",
5+
"includePath": [
6+
"${workspaceFolder}/**"
7+
],
8+
"defines": [
9+
"_DEBUG",
10+
"UNICODE",
11+
"_UNICODE"
12+
],
13+
"windowsSdkVersion": "10.0.16299.0",
14+
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe",
15+
"intelliSenseMode": "windows-msvc-x64"
16+
}
17+
],
18+
"version": 4
19+
}

Diff for: Algorithm/02 DFS.cpp

+13-12
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,23 @@ inline void optimizeIO()
4949
const int nmax = 2e5+7;
5050
const LL LINF = 1e17;
5151

52-
string to_str(LL x)
53-
{
54-
stringstream ss;
55-
ss<<x;
56-
return ss.str();
57-
}
58-
59-
//bool cmp(const PII &A,const PII &B)
60-
//{
61-
//
62-
//}
63-
6452
vector<int>adj[nmax];
6553
vector<bool>vis(nmax,false);
6654
vector<int>dist(nmax,0);
6755

56+
/**
57+
*
58+
* For tree, it is sufficient to only keep track of parent
59+
*
60+
* void dfs(int u,int p)
61+
* {
62+
* for(int v:adj[u])
63+
* if(v != p)
64+
* dfs(v,u);
65+
* }
66+
*
67+
**/
68+
6869
void dfs(int u)
6970
{
7071
vis[u] = true;

Diff for: Algorithm/07 Prim's MST.cpp

+9-40
Original file line numberDiff line numberDiff line change
@@ -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-
4627
inline void optimizeIO()
4728
{
4829
ios_base::sync_with_stdio(false);
@@ -52,49 +33,37 @@ inline void optimizeIO()
5233
const int nmax = 1e3+7;
5334
const 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-
6736
int nodes,edges;
6837

6938
vector<PII>adj[nmax];
7039

7140
LL 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
}

Diff for: Algorithm/08 Kruskal's MST.cpp

+1-31
Original file line numberDiff line numberDiff line change
@@ -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-
4627
inline void optimizeIO()
4728
{
4829
ios_base::sync_with_stdio(false);
@@ -52,17 +33,6 @@ inline void optimizeIO()
5233
const int nmax = 1e3+7;
5334
const 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-
//}
6636

6737
struct Edge {
6838
int src, dest, weight;
@@ -102,7 +72,7 @@ class DisjointSet
10272
if (parent[k] == k)
10373
return k;
10474

105-
return parent[k] =Find(parent[k]);
75+
return parent[k] = Find(parent[k]);
10676
}
10777

10878
void Union(int a, int b)

Diff for: Algorithm/38 Subtree Size.cpp

-31
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,6 @@ using namespace std;
2121
#define ALL(x) (x).begin(), (x).end()
2222
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
2323

24-
#include <ext/pb_ds/assoc_container.hpp>
25-
#include <ext/pb_ds/tree_policy.hpp>
26-
using namespace __gnu_pbds;
27-
28-
template<class TIn>
29-
using indexed_set = tree<
30-
TIn, null_type, less<TIn>,
31-
rb_tree_tag, tree_order_statistics_node_update>;
32-
33-
/*
34-
PBDS
35-
-------------------------------------------------
36-
1) insert(value)
37-
2) erase(value)
38-
3) order_of_key(value) // 0 based indexing
39-
4) *find_by_order(position) // 0 based indexing
40-
41-
*/
42-
4324
inline void optimizeIO()
4425
{
4526
ios_base::sync_with_stdio(false);
@@ -49,18 +30,6 @@ inline void optimizeIO()
4930
const int nmax = 2e5+7;
5031
const LL LINF = 1e17;
5132

52-
string to_str(LL x)
53-
{
54-
stringstream ss;
55-
ss<<x;
56-
return ss.str();
57-
}
58-
59-
//bool cmp(const PII &A,const PII &B)
60-
//{
61-
//
62-
//}
63-
6433
vector<int>adj[nmax];
6534
int sub[nmax]; /** subtree size **/
6635

Diff for: Algorithm/40 Cycle Check.cpp

-20
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,6 @@ using namespace std;
3131
#define ALL(x) (x).begin(), (x).end()
3232
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
3333

34-
#include <ext/pb_ds/assoc_container.hpp>
35-
#include <ext/pb_ds/tree_policy.hpp>
36-
using namespace __gnu_pbds;
37-
38-
template<class TIn>
39-
using indexed_set = tree<
40-
TIn, null_type, less<TIn>,
41-
rb_tree_tag, tree_order_statistics_node_update>;
42-
43-
/**
44-
45-
PBDS
46-
-------------------------------------------------
47-
1) insert(value)
48-
2) erase(value)
49-
3) order_of_key(value) // 0 based indexing
50-
4) *find_by_order(position) // 0 based indexing
51-
52-
**/
53-
5434
inline void optimizeIO()
5535
{
5636
ios_base::sync_with_stdio(false);

Diff for: Algorithm/41 Cycle Check Directed.cpp

-27
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,6 @@ using namespace std;
3030
#define ALL(x) (x).begin(), (x).end()
3131
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
3232

33-
#include <ext/pb_ds/assoc_container.hpp>
34-
#include <ext/pb_ds/tree_policy.hpp>
35-
using namespace __gnu_pbds;
36-
37-
template<class TIn>
38-
using indexed_set = tree<
39-
TIn, null_type, less<TIn>,
40-
rb_tree_tag, tree_order_statistics_node_update>;
41-
42-
/**
43-
44-
PBDS
45-
-------------------------------------------------
46-
1) insert(value)
47-
2) erase(value)
48-
3) order_of_key(value) // 0 based indexing
49-
4) *find_by_order(position) // 0 based indexing
50-
51-
**/
52-
5333
inline void optimizeIO()
5434
{
5535
ios_base::sync_with_stdio(false);
@@ -59,13 +39,6 @@ inline void optimizeIO()
5939
const int nmax = 2e5+7;
6040
const LL LINF = 1e17;
6141

62-
string to_str(LL x)
63-
{
64-
stringstream ss;
65-
ss<<x;
66-
return ss.str();
67-
}
68-
6942
vector<int>adj[nmax];
7043
vector<int>col(nmax,0);
7144

Diff for: Algorithm/41.2 Cycle Check Directed 2.cpp

-27
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,6 @@ using namespace std;
4040
#define ALL(x) (x).begin(), (x).end()
4141
#define DBG(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << endl
4242

43-
#include <ext/pb_ds/assoc_container.hpp>
44-
#include <ext/pb_ds/tree_policy.hpp>
45-
using namespace __gnu_pbds;
46-
47-
template<class TIn>
48-
using indexed_set = tree<
49-
TIn, null_type, less<TIn>,
50-
rb_tree_tag, tree_order_statistics_node_update>;
51-
52-
/**
53-
54-
PBDS
55-
-------------------------------------------------
56-
1) insert(value)
57-
2) erase(value)
58-
3) order_of_key(value) // 0 based indexing
59-
4) *find_by_order(position) // 0 based indexing
60-
61-
**/
62-
6343
inline void optimizeIO()
6444
{
6545
ios_base::sync_with_stdio(false);
@@ -69,13 +49,6 @@ inline void optimizeIO()
6949
const int nmax = 2e5+7;
7050
const LL LINF = 1e17;
7151

72-
string to_str(LL x)
73-
{
74-
stringstream ss;
75-
ss<<x;
76-
return ss.str();
77-
}
78-
7952
vector<vector<int>>adj;
8053

8154
vector<bool>vis;

0 commit comments

Comments
 (0)