| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 4 초 | 2048 MB | 4 | 4 | 4 | 100.000% |
Your social media company ConnectHub prides itself on how easily information spreads through its network.
Accounts can share posts directly with their followers using the share button, or with the accounts they follow by posting in the comments. ConnectHub is famous for the virality of its users: a post from any account was able to reach every other account, possibly through a chain of shares and comments.
But disaster struck: a database mishap wiped out all records of who follows whom. One piece of data may have survived, though — for each account, you have the number of its followers and the number of accounts it follows. Maybe even those numbers have been corrupted, but it's all you have.
Your task is to rebuild the missing database so that these counts are correct, and ConnectHub once again has full virality.
The input consists of:
Additionally, it is guaranteed that \[ \sum_{i=1}^n a_i + \sum_{i=1}^n b_i \leq 2\,000\,000. \]
Note that the input is not guaranteed to allow for any reconstruction, fully viral or not. For those familiar with that terminology, full virality is equivalent to weak connectivity.
If a reconstruction is possible, output a network
Otherwise output "impossible".
Note that it is not allowed for an account to follow the same account twice, nor to follow itself.
5 2 1 2 1 3 0 2 2 3 2
5 9 2 4 4 5 3 5 3 2 5 2 1 3 1 4 5 3 5 4
3 2 2 1 1 1 2
impossible
ICPC > Regionals > Europe > Northwestern European Regional Contest > Nordic Collegiate Programming Contest > NCPC 2025 F번