Rating changes for the last round are temporarily rolled back. They will be returned soon.
×

No tags yet

No tag edit access

The problem statement has recently been changed. View the changes.

×
Time limit per test: 0.25 second(s)

Memory limit: 65536 kilobytes

Memory limit: 65536 kilobytes

input: standard

output: standard

output: standard

Consider a digital electric circuit operating with binary signals in a discrete time. It contains input signals, wires, junctions and logical gates. We will use six kinds of logical gates: NOT, AND, NAND, OR, NOR, DFF. Each of them returns one output signal. The amount of input signals and details about return value are showed in the following table.

Gate | Inputs | Return value |

NOT | 1 | Opposite to the input signal value. |

AND | 1 or more | Conjunction of the input signal values. |

NAND | 1 or more | Negation of the conjunction of the input signal values. |

OR | 1 or more | Disjunction of the input signal values. |

NOR | 1 or more | Negation of the disjunction of the input signal values. |

DFF | 1 | Same as the input signal. Returned with the delay of one tick of discrete time. |

The scheme will operate in the following manner. Before the first tick of the discret time each DFF gate is initialized with zero value. Then during certain amount of ticks several junctions ( junctions) will be feeded with input values. You are to write a program that will calculate binary values on a certain set of junctions ( junctions).

Your program will be given the description of the logical scheme, the set of junctions in which we are interested and the input values for each consecutive tick of the discrete time.

INPUT(junction), where

junctionis the name of the junction. A line describing the interesting junction looks like

OUTPUT(junction), where

junctionis the name of the junction. A junction name consists of small and capital Latin letters and digits and the underline character "_". The length of each name is less than 64 characters.

All other lines of the first block contain the description of new junctions. Such line can look like

j1 = op(j2), where

j1and

j2are the names of junctions and

opis either

NOTor

DFF. It can also look like

j1 = op(j2[, j3...]), where

j's are the junction names and

opis

AND,

NAND,

ORor

NOR. There will be no more than 5 · 10

The second block of the input file starts with the line

INPUT VALUES. Each of the following lines contains a sequence of zeroes and ones. Amount of digits equals to the amount of input signals. You should match these binary values to the input signal values, in the order the input signals given. There are no more than 500 lines in this block. Please refer to the sample for the details.

The input file size is less than 320 KB.

You may assume that the input data is correct. You may assume that the given circuit will operate correctly.

sample input | sample output |

INPUT(a) INPUT(b) x = DFF(a) t = OR(a, b) y = AND(x, t) OUTPUT(x) OUTPUT(y) INPUT VALUES 10 11 00 | 00 11 10 |

sample input | sample output |

# 4 inputs # 1 output # 3 D-type flipflops # 2 inverters # 8 gates (1 AND+1 NAND+2 ORs+4 NORs) INPUT(G0) INPUT(G1) INPUT(G2) INPUT(G3) OUTPUT(G17) G5 = DFF(G10) G6 = DFF(G11) G7 = DFF(G13) G14 = NOT(G0) G17 = NOT(G11) G8 = AND(G14, G6) G15 = OR(G12, G8) G16 = OR(G3, G8) G9 = NAND(G16, G15) G10 = NOR(G14, G11) G11 = NOR(G5, G9) G12 = NOR(G1, G7) G13 = NOR(G2, G12) INPUT VALUES 0000 0001 0010 0100 1000 1010 | 1 0 0 0 1 1 |

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jun/19/2021 16:13:20 (j1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|