Թաքցված խնդիր
|Այս խնդիրը թաքցված է խմբագրական խրհրդի անդամի կողմից քանի որ կամ այն ոչ ճիշտ լեզվով է գրված,|կամ թեստային տվյալներն են սխալ, կամ խնդրի ձևակերպումը պարզ չէ։|

ACM_0173 - BUREAUCRACY

    Long ago, in a kingdom far, far away the king decided to keep a record of all laws of his kingdom. From that moment whenever a new law was passed, a corresponding record was added to the law archive.

   Many centuries later lawyers discovered that there were only two types of laws in the kingdom:

  • direct law, that states a new norm;
  • canceling law, that cancels one of the previous laws.

   The law is considered active if and only if there is no active law that cancels it. You are to write program that finds out which laws are still active.

Input

   The first line of the input file contains an integer number n (1 n 100 000) — the number of passed laws.

   The following n lines describe one law each. Each description has one of the following formats:

  • “declare”, meaning that a direct law was passed.
  • “cancel i”, where i is the number of law being cancelled by this one.

   The laws are numbered from one.

Output

   The first line of the output file must contain the number of active laws.  Following lines must contain numbers of these laws listed in increasing order.

Example

stdin

stdout

1

5

declare

cancel 1

declare

cancel 2

cancel 3

3

 

1 4 5

 
 
 
 
 

Ավելացրեց.Հրանտ Հովհաննիսյան
Ամսաթիվ.2014-04-09
Ժամանակի սահմանափակումը.1s
Ծրագրի տեքստի սահմանափակումը.50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Լեզուներ.Բոլորը բացի ASM32 ASM64 GAWK CLPS CLOJURE D ERL FSHARP FORTRAN GOSU HASK ICON ICK NEM NIM OBJC-CLANG PICO PIKE PYPY PYPY3 PY_NBC RUST SCM guile CHICKEN SED TCL WHITESPACE
Աղբյուրը.Northern QF 2009.B

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.