ΠΔΠ-26 (2014) - Phase A (domes)

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem types
Allowed languages
C, C++, Java, Pascal, Python

SOCIAL SOLIDARITY STRUCTURES

Due to the expansion of the economic crisis and to prevent it from taking on characteristics of social disaster, institutions (educational and non-educational), non-governmental organizations, and hundreds of collectives across Greece are developing actions of social solidarity and protection. Exchange of goods and services, distribution of essential items, provision of health services, and educational support are some of the various actions being implemented in our area.

From the beginning, it became evident that these actions are more effective when they are well-coordinated and have a broader presence throughout Greece. A key lever for both is the connection and collaboration among solidarity structures. Students from a second chance school took the initiative to document existing structures and identify those connected to fewer than two other structures.

Problem

Develop a program in one of the IOI languages that, after reading a file containing the list of existing connections in a network of solidarity structures, returns the number of structures with fewer than two connections.

Input Files

The input file domes.in is a text file in the following format: The first line contains two integers, N and M, separated by a space. N is the number of solidarity structures, numbered from 1 to N. M is the number of connections that exist. Following are M lines, each containing a pair of integers, A and B (1 \le A \le N, 1 \le B \le N, and A \neq B), separated by a space. The pair A, B represents a bidirectional connection between structures A and B.

Output Files

The output file domes.out is a text file in the following format: It has only one line containing a single integer P\;(0 \le P \le N): the number of structures that have fewer than two connections.

Examples of Input - Output Files:
1st

STDIN (domes.in)

6 7
2 4
4 1
3 5
4 3
1 3
5 1
5 6

STDOUT (domes.out)

2
2nd

STDIN (domes.in)

7 9
5 7
4 2
3 6
2 3
1 7
6 2
4 6
1 5
3 4

STDOUT (domes.out)

0
Constraints:

2 \le N \le 100.000
1 \le M \le 10.000.000
Time Limit: 1sec.
Maximum Available Memory: 64MB.


Comments

There are no comments at the moment.