| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 11 | 7 | 7 | 77.778% |
In the Kingdom of Utopia, society has become highly digitized, even in relationships. The governor has built a massive database system of billions of GPUs to record relationships of its residents. Between any two residents, it is required that if they are acquaintances, they have to be registered in the kingdom’s database. Note that a registered relationship is mutual: if $A$ is registered to be an acquaintance of $B,ドル then $B$ is also registered as an acquaintance of $A$.
In the last effort to fully digitize relationships, King Aurelius IV proposes “numerical affectionate points”. Every resident of the Utopia Kingdom is given 10ドル,円 000$ affectionate points. The residents are then required to distribute their affectionate points to the other residents that have registered their relationship in the database. For example, if $A$ has registered to be an acquaintance to $B$ and $C,ドル $A$ can distribute 3ドル,円 000$ affectionate points to $B,ドル and 7ドル,円 000$ affectionate points to $C$. If $A$ is not registered to $D,ドル $A$ can not give $D$ any affectionate point. Residents can distribute any integral quantity of affection points, from 0ドル$ to 10ドル,円 000$ inclusive.
The King wants to make sure that points distribution is fair and equal: if $A$ gives $B$ $x$ affectionate point, then $B$ must also give $A$ the same $x$ affectionate points. Further, a resident must also distribute all of their affectionate points; the sum of all affectionate points that a resident distributes to their acquaintances must be 10ドル,円 000$.
The King gives you the database of registered relationships, and he wants you to figure out if it is possible for the Kingdom to implement this protocol. You must determine if the king’s scheme is possible, and if it is, you must give the King a valid affectionate point distribution.
The first line of input contains two integers $n$ (2ドル \le n \le 1,円 000$) and $m$ (1ドル \le m \le 5,円 000$), where $n$ is the number of citizens of Utopia, and $m$ is the number of registered relationships. The citizens are numbered from 1ドル$ to $n$.
Each of the next $m$ lines contains two integers $a$ and $b$ (1ドル \le a,b \le n, a \neq b$), describing a registered relationship between citizens $a$ and $b$. All relationships will be unique. If $a$ $b$ appears in the input, then $a$ is an acquaintance of $b$ and $b$ is an acquaintance of $a,ドル so $b$ $a$ will not appear in the input.
If it is possible to distribute Affection Points as the king requires, then output $n$ lines, each containing $n$ integers. The number at position $(i,j)$ is the number of Affection Points between citizens $i$ and $j$. Note that along the diagonal where $i=j,ドル the number of affection points is clearly 0ドル$.
If it is not possible to distribute Affection Points as the king requires, simply output $-1$.
5 6 1 2 1 3 2 3 3 4 3 5 5 4
0 7500 2500 0 0 7500 0 2500 0 0 2500 2500 0 2500 2500 0 0 2500 0 7500 0 0 2500 7500 0
6 5 1 2 3 1 3 2 4 5 6 5
-1
ICPC > Regionals > North America > North America Qualification Contest > ICPC North America Qualifier 2025 M번
University > MIT > The MIT Programming Contest > 2025-26 > MIT Team Contest 1 M번