Skip to content

Commit d8ef03b

Browse files
committed
updated
1 parent ac60635 commit d8ef03b

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*-----------------------------AIR-1-----------------------------------------*/
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
5+
/*----------------------------------------------------------------------------*/
6+
typedef long long ll;
7+
typedef vector<int> vi;
8+
9+
/*----------------------------------------------------------------------------*/
10+
#define MOD 1e9 + 7
11+
#define pb push_back
12+
#define ppb pop_back
13+
#define f first
14+
#define s second
15+
#define nl "\n"
16+
#define pie 3.141592653589793238462
17+
#define set_bits(x) __builtin_popcountll(x)
18+
#define all(x) (x).begin(), (x).end()
19+
#define debug(x) cerr<<x<<" "
20+
#define loop(i,a,b) for(int i=(a);i<(b);i++)
21+
#define printvector(x) for(auto i:(x)) cout<<(i)<<" "
22+
23+
/*----------------------------------------------------------------------------*/
24+
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
25+
template<typename T> T binpow(T base,T power){ ll ans=1; while(power){if(power&1) ans=ans*base; base=base*base; power>>=1;}return ans;}
26+
27+
28+
/*----------------------------------------------------------------------------*/
29+
class graph
30+
{
31+
public:
32+
unordered_map<int,vector<pair<int,int>>>adjlist;
33+
void addedge(int from,int to,int weight)
34+
{
35+
36+
adjlist[from].pb({to,weight});
37+
}
38+
void printlist()
39+
{
40+
for(auto it:adjlist)
41+
{
42+
cout<<"from->"<<it.first<<" to-> ";
43+
for(auto nbr:it.second)
44+
{
45+
cout<<"("<<nbr.f<<","<<nbr.s<<")";
46+
}
47+
cout<<endl;
48+
}
49+
}
50+
};
51+
int main()
52+
{
53+
ios_base::sync_with_stdio(0);
54+
cin.tie(0);
55+
56+
graph g;
57+
int nodes;
58+
cin>>nodes;
59+
while(nodes--)
60+
{
61+
int from,to,weight;
62+
cin>>from>>to>>weight;
63+
g.addedge(from,to,weight);
64+
}
65+
g.printlist();
66+
67+
68+
}
69+
70+
71+
/*
72+
input:
73+
4
74+
0 1 5
75+
0 2 8
76+
1 3 4
77+
2 3 6
78+
*/

0 commit comments

Comments
 (0)