Universal Cup Judging System

Universal Cup

时间限制: 2.0 s 内存限制: 1024 MB 总分: 100 可 Hack ✓
统计

Mô tả bài toán

Một kỳ thi không thể thiếu bài toán cấu trúc dữ liệu, ngay cả khi đó chỉ là một bài toán tặng bóng bay.

Bạn được cho một ma trận $M$. Gọi phần tử ở hàng thứ $i$ và cột thứ $j$ của ma trận là $M_{i,j}$, và gọi số hàng cùng số cột lần lượt là $n$ và $m$. Ban đầu, $n=m=1$, và $M_{1,1}=c$.

Bạn cần thực hiện $q$ thao tác, mỗi thao tác thuộc một trong ba loại sau:

  • 1 x y ($0\le x\le n$, $1\le y\le 10^9$) chèn một hàng có giá trị $y$ vào giữa hàng thứ $x$ và hàng thứ $(x+1)$; sau thao tác này, $n$ tăng thêm $1$;

  • 2 x y ($0\le x\le m$, $1\le y\le 10^9$) chèn một cột có giá trị $y$ vào giữa cột thứ $x$ và cột thứ $(x+1)$; sau thao tác này, $m$ tăng thêm $1$;

  • 3 x y ($1\le x\le n$, $1\le y\le m$) truy vấn giá trị của $M_{x,y}$.

Dữ liệu vào

Dòng đầu tiên của dữ liệu vào chứa hai số nguyên $q,c$ ($1\le q\le 5\cdot 10^5$, $1\le c\le 10^9$).

$q$ dòng tiếp theo, mỗi dòng mô tả một thao tác.

Ba số nguyên $opt,x,y$ ở đầu mỗi dòng ($opt\in\{1,2,3\}$) có ý nghĩa như đã mô tả trong đề bài ở trên.

Kết quả

Đối với mỗi thao tác truy vấn, in ra một dòng chứa một số nguyên biểu thị câu trả lời.

Ví dụ

Dữ liệu vào 1

6 1
1 0 2
3 2 1
2 1 3
1 1 4
3 2 2
3 3 2

Kết quả 1

1
4
3

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.