File tree Expand file tree Collapse file tree 1 file changed +13
-20
lines changed Expand file tree Collapse file tree 1 file changed +13
-20
lines changed Original file line number Diff line number Diff line change 22#include < list>
33using namespace std ;
44
5- class Graph
6- {
5+ class Graph {
76int V;
87list<int >* adj;
98public:
10- Graph (int V)
11- {
9+ Graph (int V) {
1210this ->V = V;
1311adj = new list<int >[V];
1412}
15- ~Graph ()
16- {
13+
14+ ~Graph () {
1715delete[] adj;
1816}
1917
2018void addEdge (int v, int w);
2119};
2220
23- void Graph::addEdge (int v, int w)
24- {
21+ void Graph::addEdge (int v, int w) {
2522adj[v].push_back (w);
2623adj[w].push_back (v);
2724}
2825
29- int main ()
30- {
26+ int main () {
3127ios_base::sync_with_stdio (false );
3228cin.tie (NULL );
3329int N, M;
3430cin >> N >> M;
3531int u[100 ], v[100 ], counter[100 ];
32+
3633Graph g (N);
37- for (int i = 0 ; i < M; i++)
38- {
34+ for (int i = 0 ; i < M; i++) {
3935cin >> u[i] >> v[i];
4036g.addEdge (u[i], v[i]);
4137}
42- for (int i = 0 ; i < N; i++)
43- {
38+ for (int i = 0 ; i < N; i++) {
4439counter[i] = 0 ;
45- for (int j = 0 ; j < M; j++)
46- {
40+ for (int j = 0 ; j < M; j++) {
4741if (u[j] == i or v[j] == i)
4842counter[i]++;
4943}
5044}
45+
5146int result = 0 ;
5247int min = -1 ;
5348int max = -1 ;
54- for (int j = 0 ; j < N; j++)
55- {
56- if (counter[j] % 2 != 0 )
57- {
49+ for (int j = 0 ; j < N; j++) {
50+ if (counter[j] % 2 != 0 ) {
5851result++;
5952if (min == max)
6053min = j;
You can’t perform that action at this time.
0 commit comments