CCF-CSP: 201909-2 Xiao Ming apples (cont.)

topic

Number: 201909-2

Questions Name: Bob apples (cont.)

Time limit: 1.0s

Memory Limit: 512.0MB

Title Description

  Xiao Ming in his orchard planted some apple trees, the apple trees are arranged in a circle. In order to ensure the quality of Apple, during the planting process to be thinning operations. In order to complete the thinning operation more promptly, Xiaoming sometimes checks the status of each tree, as required for thinning. Check, if we find there may be apple fall from a tree, Xiao Ming will recount the number of apple trees (and based on the record before we can determine whether there is a falling apple). At the end of all operations, please help Xiao Ming statistically relevant information.

Input Format

  Data is read from the standard input.
  Line 1 contains a positive integer \ (N \) , represents the number of apple trees.
  The first \ (1 + i \) row ( \ (. 1 \ Le I \ Le N \) ), the format of each line is \ (m_i, a_ {i1} , a_ {i2}, \ dots, a_ {im_i} \ ) . Wherein the first positive integer \ (m_i \) represents the number of integers following the Bank. Subsequent \ (m_i \) integer represents the first Bob \ (I \) operation record of apple trees. If \ (a_ {ij} (1 \ le i \ le m_i) \) is a positive integer, then re Xiaoming statistical operation performed on the number of the apple tree, the statistics of the number of apples \ (a_ { } ij of \) ; if zero or negative integer, then a thinning operation, the number is removed Apple \ (| ij of A_ {} | \) .
  Input is guaranteed the right to meet:

  1. \ (A_ {I1}> 0 \) , i.e., the recording of each tree, the first operation of Apple must count the number (the initial state, then determines whether or not falling apple);
  2. The number after each apple tree thinning operations to ensure that the operation is still positive.

Output Format

  Output to standard output.
  Only output line, comprising three integers \ (T, D, E \) . among them,

  • \ (T \) is the end of all thinning operations on all the rest of the total apple apple tree (assuming that each of them at last count apple apple tree will not be reduced for reasons other than Apple thinning the number of operations);
  • \ (D \) a few trees to happen apple falling apple trees;
  • \ (E \) array apple fall from happening is contiguous to three trees.
      For the interpretation of the third statistic: \ (N \) apple trees \ (A_1, A_2, \ dots , A_N \) are arranged in a circle, then \ (A1 \) and \ (A2 \) adjacent \ (A2 \) and \ (A3 \) adjacent, \ (\ DOTS \) , \ (A_. 1-N {} \) and \ (A_N \) adjacent, \ (A_N \) and \ (A_1 \) neighbor. If \ (A_ {i-1} , A_i, A_ {i + 1} \) which have taken place in the case of three trees of apple fall, is referred to as a group. Formal, there
    \ [E = | {A_i |
    Drop (Pred (A_i) \ wedge Drop (A_i) \ wedge Drop (Succ (A_i))} | \] wherein, \ (the Drop (A_i) \) represents Apple tree \ (A_i \) whether there apple fall occurs, \ (Pred Forte (A_i) \) represents \ (A_i \) in front of a tree \ (A_ {i-1} \)(If \ (I>. 1 \) ) or \ (A_N \) (if \ (= I. 1 \) ), \ (Succ (A_ +. 1 {I}) \) represents \ (A_i \) after a tree \ (A_. 1} + {I \) (if \ (I <N \) )
    or \ (A_1 \) (if \ (I = N \) ).

Sample data

Sample input 1

4
4 74 -7 -12 -5 
5 73 -8 -6 59 -4
5 76 -5 -10 60 -2
5 80 -6 -15 59 0

Sample output
222 1 0

Sample 1 explained
  after the end of the entire operation, the remaining number of apples on the tree for the first \ (74-7-12-5 = 50 \) , the first two as \ (59-4 = 55 \) , the first 3 is a \ (60-2 = 58 \) , for the first 4 \ (59-0 = 59 \) . Thus \ (T = 50 + 55 + 58 + 59 = 222 \) .
  Among them, the number of apple trees before 3rd 2nd statistics for the remainder of \ (76-5-10 = 61> 60 \) , so Apple dropped the case occurred. Other tree can be checked is not the case, so \ (D =. 1 \) .
  No continuous three trees are falling apples circumstances occur, so \ (E = 0 \) .

Sample input 2

5
4 10 0 9 0
4 10 -2 7 0
2 10 0
4 10 -3 5 0
4 10 -1 8 0

Sample output 2
39 4 2

Sample 2 illustrates
  the first situation occurs 1,2,4,5 apple tree falling, so \ (D =. 4 \) . Among them, three trees have undergone continuous Apple has dropped the case of (5,1,2) and (4,5,1), therefore \ (E = 2 \) .

Subtasks

Numbering N \(max\\{ m_i \\}\)
1,2 3 2
3,4 10 10
5,6 10 100
7,8 100 100
9,10 1000 1000
  • \ (m_i \ 1000 \) ,对所有\ (1 \ and i \ and N \)
  • \ (| a_ {ij} | \ 10 ^ 6 \) ,对所有\ (1 \ i \ N, 1 \ j \ m \) ;

prompt

  • If your program does not achieve statistical \ (D \) and \ (E \) function, follow (D = 0, E = 0 \) \ output, so if \ (T \) is correct statistics can be part of fraction.
  • If your program does not achieve statistical \ (E \) function, follow \ (E = 0 \) output, so if \ (T \) and (D \) \ statistics can be part of the correct score.

answer

SiriYang's Blog | CCF-CSP: 201909-2 Xiao Ming apples (cont.)

Guess you like

Origin www.cnblogs.com/SiriYang/p/12121197.html