#C10225. Network Packets Analyzer
Network Packets Analyzer
Network Packets Analyzer
This problem involves analyzing network packet data. You are given a single input line containing packet information separated by semicolons. Each packet is represented by three comma-separated values: the source address, the destination address, and the packet size (a positive integer).
Your task is to compute and output four values: the total number of packets, the number of unique source addresses, the total size of all packets, and the average packet size. The average packet size is defined as the floor division of the total size by the number of packets. In the case of an empty input, all outputs should be 0.
Mathematical Formulation:
Let \(n\) be the number of packets, \(S\) be the set of source addresses, and \(T\) be the sum of packet sizes. Then, the output is given by:
\(n\quad |S|\quad T\quad \lfloor T/n \rfloor\)
inputFormat
A single line from standard input containing packet information separated by semicolons. Each packet is described by three comma-separated fields: source address, destination address, and packet size. An empty input string denotes no packets.
outputFormat
Four space-separated integers representing the total number of packets, the number of unique source addresses, the total size of packets, and the average packet size (rounded down).## sample
192.168.1.1,192.168.1.2,100
1 1 100 100