| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 256 MB | 26 | 17 | 7 | 70.000% |
Thomas Edison stumbled upon an alien electrical device that appears to break known laws of physics! The device consists of $n$ batteries connected by $m$ unidirectional wires, which we will represent as vertices and edges that form a graph. The $i$-th wire is directed from battery $v_i$ to battery $u_i,ドル $v_i \ne u_i$. Let $(v_i → u_i)$ denote such a wire.
To make this device work, Thomas must assign a current strength to each wire such that this assignment results in a successful configuration. For a configuration to be successful, two conditions must be met:
Help him with this task.
The first line contains two integers $n$ and $m$ – the number of batteries and the number of wires in the device, respectively. Next, $m$ lines contain two integers each $v_i$ and $u_i,ドル which mean that the $i$-th wire goes from battery $v_i$ to $u_i$.
Print $m$ lines containing one number each: the $i$-th number should be the current strength of $i$-th wire (in AAMP). Each number should be non-zero and in the range of $[-1000, 1000]$. If multiple answers exist, you may print any one of them.
4 7 1 2 2 3 3 1 1 4 2 4 1 4 3 2
-1 -1 2 -2 -1 -2 1
Note that there can be multiple wires from battery $x$ to $y$. Also note that wire $(x → y)$ with strength 3ドル$ AAMP is not the same as $(y → x)$ with strength $-3$. As mentioned before, wires are unidirectional and can have a negative current strength - that’s one of the mysteries of this device ...