QOJ.ac

QOJ

时间限制: 4 s 内存限制: 512 MB 总分: 100 交互

#9972. Doomsday Magical Girl Project

统计

Given a monoid $(D,+,e)$ and a sequence $a_1, \dots, a_n$ of elements in $D$, all initially set to $e$, support $m$ operations, where each operation is either a point update or a range sum query.

The number of times the $+$ operation is used in each update is limited to at most $M_1$.

The number of times the $+$ operation is used in each query is limited to at most $M_2$.

Basic properties of the monoid:

$\forall a\in D,\; e+a=a+e=a$

$\forall a,b,c\in D,\;(a+b)+c=a+(b+c)$

This is an interactive problem. You need to include the header file lib.h or place its content at the beginning of your program.

The content of the provided header file lib.h is as follows:

struct Data{
    unsigned short a,b,c,d;
};
Data operator+(Data a,Data b);

void init(int n,int k,Data d);
void update(int x,Data d);
Data query(int l,int r);

Here, Data represents $D$, and Data operator+ represents $+$. The interactive library provides the implementation for these.

You need to implement:

init: Used for initialization. $n, k, d$ represent $n, M_2$, and the identity element $e$ of $D$, respectively. You may use $+$, but since $e+e=e$, it cannot yield useful results.

update: Represents an update operation, changing $a_x$ to $d$.

query: Represents a range sum query, calculating $a_l+a_{l+1}+\dots+a_r$. The result of the query should be returned.

Subtasks

For all test cases, $n=10^5$ and $m=2\times 10^5$.

Test Case ID $M_1$ $M_2$ Score
1 4000 2 11
2 700 3 7
3 400 4 5
4 200 5 4
5 200 6 4
6 100 7 3
7 80 8 3
8 60 9 3
9 2811 2 16
10 542 3 11
11 272 4 8
12 137 5 7
13 113 6 5
14 75 7 5
15 69 8 4
16 48 9 4

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.