CF1252G.Performance Review

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Randall is a software engineer at a company with NN employees. Every year, the company re-evaluates its employees. At the end of every year, the company replaces its several worst-performing employees and replaces with the same number of new employees, so that the company keeps having NN employees. Each person has a constant performance and can be represented by an integer (higher integer means better performance), and no two people have the same performance.

The performance of the initial employees are represented by an array of integers A=[A1,A2,…,AN]A = [A_1, A_2, \dots, A_N] where AiA_i is the performance of the ithi^{th} employee. Randall is employee 11, so his performance is A1A_1. We will consider the first MM years. At the end of the ithi^{th} year, the company replaces its RiR_i worst-performing employees and replaces with RiR_i new employees. The performance of these new employees are represented by an array of integers Bi=[(Bi)1,(Bi)2,…,(Bi)Ri]B_i = [(B_i)_1, (B_i)_2, \dots, (B_i)_{R_i}] where (Bi)j(B_i)_j is the performance of the jthj^{th} new employee.

He will consider QQ scenarios. On the ithi^{th} scenario, he will change the value of (BXi)Yi(B_{X_i})_{Y_i} to ZiZ_i. For each scenario, Randall is wondering whether he will still be in the company after MM years. Note that the changes in each scenario are kept for the subsequent scenarios.

兰德尔是一家拥有 NN 名员工的公司的软件工程师。每年,公司都会对员工进行绩效评估。每年年末,公司会淘汰若干名绩效最差的员工,并招聘相同数量的新员工,以确保公司始终维持 NN 名员工。每位员工的绩效为一个固定整数(数值越大表示绩效越好),且任意两名员工的绩效均不相同。

初始员工的绩效用一个整数数组 A=[A1,A2,…,AN]A = [A_1, A_2, \dots, A_N] 表示,其中 AiA_i 表示第 ii 位员工的绩效。兰德尔是第 11 号员工,因此他的绩效为 A1A_1。我们考虑前 MM 年的情况。在第 ii 年年末,公司会淘汰 RiR_i 名绩效最差的员工,并招聘 RiR_i 名新员工。这些新员工的绩效用一个整数数组 Bi=[(Bi)1,(Bi)2,…,(Bi)Ri]B_i = [(B_i)_1, (B_i)_2, \dots, (B_i)_{R_i}] 表示,其中 (Bi)j(B_i)_j 表示第 jj 名新员工的绩效。

兰德尔将考虑 QQ 种情形。在第 ii 种情形中,他将把 (BXi)Yi(B_{X_i})_{Y_i} 的值修改为 ZiZ_i。对于每种情形,兰德尔想知道:在经历 MM 年后,他是否仍留在公司中。注意:每种情形所做的修改会持续保留至后续情形中。

输入格式

Input begins with a line containing three integers: NN MM QQ (2≤N≤100 0002 \le N \le 100\,000; 1≤M,Q≤100 0001 \le M, Q \le 100\,000) representing the number of employees, the number of years to be considered, and the number of scenarios, respectively. The next line contains NN integers: AiA_i (0≤Ai≤1090 \le A_i \le 10^9) representing the performance of the initial employees. The next MM lines each contains several integers: RiR_i (Bi)1(B_i)_1, (Bi)2(B_i)_2, ⋯\cdots, (Bi)Ri(B_i)_{R_i} (1≤Ri<N1 \le R_i \lt N; 0≤(Bi)j≤1090 \le (B_i)_j \le 10^9) representing the number of employees replaced and the performance of the new employees, respectively. It is guaranteed that the sum of RiR_i does not exceed 10610^6. The next QQ lines each contains three integers: XiX_i YiY_i ZiZ_i (1≤Xi≤M1 \le X_i \le M; 1≤Yi≤R(Xi)1 \le Y_i \le R_{(X_i)}; 0≤Zi≤1090 \le Z_i \le 10^9) representing a scenario. It is guaranteed that all integers in all AiA_i, (Bi)j(B_i)_j, and ZiZ_i (combined together) are distinct.

输入的第一行包含三个整数:NN、MM、QQ(2≤N≤100 0002 \le N \le 100\,000;1≤M,Q≤100 0001 \le M, Q \le 100\,000),分别表示员工人数、需考虑的年数以及场景数量。
第二行包含 NN 个整数:AiA_i(0≤Ai≤1090 \le A_i \le 10^9),表示初始员工的绩效值。
接下来的 MM 行,每行包含若干整数:RiR_i、(Bi)1(B_i)_1、(Bi)2(B_i)_2、⋯\cdots、(Bi)Ri(B_i)_{R_i}(1≤Ri<N1 \le R_i \lt N;0≤(Bi)j≤1090 \le (B_i)_j \le 10^9),分别表示第 ii 年被替换的员工人数,以及新员工的绩效值。保证所有 RiR_i 的总和不超过 10610^6。
接下来的 QQ 行,每行包含三个整数:XiX_i、YiY_i、ZiZ_i(1≤Xi≤M1 \le X_i \le M;1≤Yi≤R(Xi)1 \le Y_i \le R_{(X_i)};0≤Zi≤1090 \le Z_i \le 10^9),表示一个场景。保证所有 AiA_i、(Bi)j(B_i)_j 和 ZiZ_i(合并在一起)中的整数互不相同。

输出格式

For each scenario in the same order as input, output in a line an integer 00 if Randall will not be in the company after MM years, or 11 if Randall will still be in the company after MM years.

对于输入中每个场景(按相同顺序),在一行中输出一个整数:若 MM 年后 Randall 将不在该公司,则输出 00;若 MM 年后 Randall 仍将在该公司,则输出 11。

输入输出样例

  • 输入#1

    5 3 3
    50 40 30 20 10
    4 1 2 3 100
    1 4
    2 6 7
    1 3 300
    2 1 400
    2 1 5

    输出#1

    1
    0
    1

说明/提示

Explanation for the sample input/output #1

Randall performance is represented by 5050. For the first scenario, the value of (B1)3(B_1)_3 is updated to 300300, causes the following:

  • Initially, the performance of the employees is [50,40,30,20,10][50, 40, 30, 20, 10].
  • At the end of the first year, 44 worst-performing employees are replaced by employees with performance [300,100,2,1][300, 100, 2, 1]. Therefore, the performance of the employees is [300,100,50,2,1][300, 100, 50, 2, 1].
  • At the end of the second year, the performance of the employees is [300,100,50,4,2][300, 100, 50, 4, 2].
  • At the end of the third year, the performance of the employees is [300,100,50,7,6][300, 100, 50, 7, 6].

Therefore, Randall will still be in the company after 33 years.

For the second scenario, the value of (B2)1(B_2)_1 is updated to 400400, causes the following:

  • Initially, the performance of the employees is [50,40,30,20,10][50, 40, 30, 20, 10].
  • At the end of the first year, the performance of the employees is [300,100,50,2,1][300, 100, 50, 2, 1]. Recall that the change in the first scenario is kept for this scenario as well.
  • At the end of the second year, the performance of the employees is [400,300,100,50,2][400, 300, 100, 50, 2].
  • At the end of the third year, the performance of the employees is [400,300,100,7,6][400, 300, 100, 7, 6].

Therefore, Randall will not be in the company after 33 years.

样例输入/输出 #1 的说明

兰德尔的绩效值为 5050。对于第一种情形,(B1)3(B_1)_3 的值被更新为 300300,导致如下变化:

  • 初始时,员工的绩效值为 [50,40,30,20,10][50, 40, 30, 20, 10]。
  • 第一年末,绩效最低的 44 名员工被绩效值为 [300,100,2,1][300, 100, 2, 1] 的新员工替代。因此,员工的绩效值变为 [300,100,50,2,1][300, 100, 50, 2, 1]。
  • 第二年末,员工的绩效值变为 [300,100,50,4,2][300, 100, 50, 4, 2]。
  • 第三年末,员工的绩效值变为 [300,100,50,7,6][300, 100, 50, 7, 6]。

因此,兰德尔在 33 年后仍将留在公司。

对于第二种情形,(B2)1(B_2)_1 的值被更新为 400400,导致如下变化:

  • 初始时,员工的绩效值为 [50,40,30,20,10][50, 40, 30, 20, 10]。
  • 第一年末,员工的绩效值为 [300,100,50,2,1][300, 100, 50, 2, 1]。(注意:第一种情形中的修改在此情形中同样生效。)
  • 第二年末,员工的绩效值变为 [400,300,100,50,2][400, 300, 100, 50, 2]。
  • 第三年末,员工的绩效值变为 [400,300,100,7,6][400, 300, 100, 7, 6]。

因此,兰德尔在 33 年后将不再留在公司。

输入解题思路,AI测评打分。不知道怎么写?

首页