1399 - I2P (II) 2018_Yang_Lab1 Scoreboard

Time

2018/03/09 13:30:00 2018/03/09 15:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10244 moocFinal4_高維度稀疏向量
11830 Play cards 2

10244 - moocFinal4_高維度稀疏向量   

Description

輸入兩個向量,計算向量內積值。
兩個向量的內積,是各項相乘然後加總。例如 [1,2,3] 和 [4,5,6] 內積是 1*4+2*5+3*6 = 32
我們考慮高維度的稀疏向量,也就是大多數的元素都是零,只有少數不為零。資料的表示方式如下
dim1: value1 dim2: value2 dim3:value3 … 0:0
最後以 0:0 結束。例如
向量 [0,5,0,0,9,0,0,33] 是一個 8 維向量,可表示成
2:5 5:9 8:33 0:0
值為0 的維度都可以忽略不需描述,只需記錄非零的維度。利用上述的表示法,讀取兩個向量,然後算出它們的內積。

Input

輸入兩行,分別對應到兩個整數向量。
向量維度最高不超過 2 的 31 次方。記憶體用量不超過 32 MB。每一行都是以 0:0 結束

Output

內積值
最後記得換行

Sample Input  Download

Sample Output  Download

Tags




Discuss




11830 - Play cards 2   

Description

Niflheimr is playing cards again!
One day, one of his friends, Ken, suspect that Niflheimr was cheating while shuffling cards. Fortunately, Niflheimr records all the operations he did while shuffling cards, so he wants to undo those operations step by step to find out the original card stack. As an intellegent CS student, let's write a program to help Niflheimr prove his innocence!

Input

First line of input contains two integer nm, representing # of cards and # of operations.
 
Next line contains n integers, representing the number on each card from the top (index 0) to the buttom (index n-1) after doing all operations.
 
Each of the next m lines contains an operation. Operations are in original order.
An operation consists of two integers a and b, meaning Niflheimr moves cards whose index are between a and a+b-1 ( [a, a+b) ) to the top of the card stack. Order of the cards inside the moved part won't be changed.
Index of a card means # of cards on the top of that cardIt may change after operations.
 
 
It is guaranteed that:
  • 1 ≤ n, m ≤ 104
  • Number on cards are non-negative integer and do not exceed 107
  • In each operation, card with index = a+b-1 always exists.

Output

Print out the original card stack from top (index 0) to buttom (index n-1), each number occupies one line.

Sample Input  Download

Sample Output  Download

Tags




Discuss