#P1038. [NOIP 2003 提高组] 神经网络
[NOIP 2003 提高组] 神经网络
Description
In Lanlan’s model, a neural network is a directed graph whose nodes are called neurons, and there is at most one edge between any two neurons. The figure below shows an example of one neuron.

Neuron (index ).
In the figure, are input channels, are output channels, is the current state of the neuron, and is the threshold, which can be regarded as an intrinsic parameter of the neuron.
Neurons are arranged in order to form the entire neural network. In Lanlan’s model, neurons are divided into multiple layers: the input layer, the output layer, and several intermediate layers. Each layer only outputs information to the next layer and only receives information from the previous layer. The figure below shows a simple three-layer neural network.

Lanlan stipulates that follows the formula (where is the total number of neurons in the network):
$$C_i=\left(\sum\limits_{(j,i) \in E} W_{ji}C_{j}\right)-U_{i}$$Here, (which may be negative) denotes the weight of the edge connecting neuron to neuron . When is greater than , the neuron is excited; otherwise, it is calm. When a neuron is excited, in the next second it will send signals to other neurons, with signal strength equal to .
Thus, after the neurons in the input layer are stimulated, the entire network operates under the push of information transmission. Now, given a neural network and the current states of the input-layer neurons, compute the final states of the output layer.
Input Format
The first line contains two integers () and . The next lines each contain integers; the -th line gives neuron ’s initial state and its threshold . Non–input-layer neurons start with state . The following lines each contain three integers , , and (where and may be negative), indicating a directed edge from neuron to neuron with weight .
Output Format
Output several lines, each containing integers: a neuron’s index and its final state, separated by a space. Output only those output-layer neurons whose final state is greater than , in ascending order of index. If all output-layer neurons have final state less than or equal to , output NULL.
5 6
1 0
1 0
0 1
0 1
0 1
1 3 1
1 4 1
1 5 1
2 3 1
2 4 1
2 5 1
3 1
4 1
5 1
Hint
[Problem Source]
NOIP 2003 Senior, Problem 1.
Translated by ChatGPT 5
京公网安备 11011102002149号