#C14388. Concurrent URL Status Fetcher
Concurrent URL Status Fetcher
Concurrent URL Status Fetcher
Your task is to develop a program that reads a list of URLs from standard input and concurrently fetches their HTTP status codes. In a real-world scenario, one might perform network requests; however, for this problem, you will simulate a network call as follows:
- If the URL contains the substring
https://httpbin.org/status/
, then the status code is the integer immediately following this substring. For example, forhttps://httpbin.org/status/200
, the status code is200
. - If the URL does not match this pattern, then it is considered unreachable and you should output
unreachable
.
You are encouraged to implement your solution using concurrent programming techniques (e.g., threads) to handle a large number of URLs efficiently.
inputFormat
The input is given via standard input. The first line contains an integer N (1 ≤ N ≤ 105), which represents the number of URLs. Each of the following N lines contains a single URL as a string.
outputFormat
For each URL provided in the input, output a line that contains the original URL followed by a space and then the corresponding HTTP status code or the string unreachable
if the URL does not match the expected pattern.
2
https://httpbin.org/status/200
https://httpbin.org/status/204
https://httpbin.org/status/200 200
</p>