mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 21:08:47 +00:00
#1584. 【ABC253F】Operations on a Matrix
https://sjzezoj.com/submission/57847
This commit is contained in:
parent
2204c5110c
commit
3471c32f09
103
S2OJ/1584/1584.cpp
Normal file
103
S2OJ/1584/1584.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
#include <iostream>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 2e5 + 5;
|
||||
|
||||
int n, m, q, idx, cnt, lst[N];
|
||||
long long c[N], val[N], ans[N];
|
||||
std::vector<std::tuple<int, int, int>> changes;
|
||||
std::vector<std::tuple<int, int, bool>> queries[N];
|
||||
|
||||
int lowbit(int x) {
|
||||
return x & -x;
|
||||
}
|
||||
|
||||
void add(int x, int y) {
|
||||
for (; x <= m; x += lowbit(x)) c[x] += y;
|
||||
}
|
||||
|
||||
long long sum(int x) {
|
||||
long long res = 0;
|
||||
for (; x; x -= lowbit(x)) res += c[x];
|
||||
return res;
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> m >> q;
|
||||
|
||||
changes.emplace_back(1, n, 0);
|
||||
|
||||
for (int i = 1; i <= q; i++) {
|
||||
int op;
|
||||
|
||||
cin >> op;
|
||||
|
||||
switch (op) {
|
||||
case 1: {
|
||||
int l, r, x;
|
||||
|
||||
cin >> l >> r >> x;
|
||||
|
||||
changes.emplace_back(l, r, x);
|
||||
idx++;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: {
|
||||
int i, x;
|
||||
|
||||
cin >> i >> x;
|
||||
|
||||
lst[i] = idx;
|
||||
val[i] = x;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 3: {
|
||||
int i, j;
|
||||
|
||||
cin >> i >> j;
|
||||
|
||||
ans[++cnt] = val[i];
|
||||
queries[lst[i]].emplace_back(j, cnt, false);
|
||||
queries[idx].emplace_back(j, cnt, true);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < changes.size(); i++) {
|
||||
int l, r, x;
|
||||
|
||||
std::tie(l, r, x) = changes[i];
|
||||
|
||||
add(l, x);
|
||||
add(r + 1, -x);
|
||||
|
||||
for (auto query : queries[i]) {
|
||||
int pos, id, type;
|
||||
|
||||
std::tie(pos, id, type) = query;
|
||||
|
||||
if (type) ans[id] += sum(pos);
|
||||
else ans[id] -= sum(pos);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i <= cnt; i++) {
|
||||
cout << ans[i] << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
S2OJ/1584/data/data1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data11.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data11.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data12.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data12.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data12.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data13.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data13.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data13.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data14.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data14.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data14.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data14.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data15.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data15.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data15.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data15.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data16.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data16.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data16.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data16.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data17.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data17.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data17.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data17.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data18.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data18.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data18.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data18.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data19.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data19.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data19.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data19.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data20.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data20.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data20.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data20.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data21.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data21.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data21.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data21.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data22.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data22.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data22.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data22.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data23.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data23.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data23.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data23.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data24.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data24.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data24.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data24.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data25.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data25.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data25.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data25.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data26.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data26.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data26.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data26.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data27.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data27.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data27.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data27.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data28.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data28.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data28.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data28.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data29.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data29.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data29.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data29.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data30.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data30.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data30.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data30.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data31.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data31.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data31.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data31.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/data9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/data9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/ex_data1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/ex_data1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/ex_data1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/ex_data1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/ex_data2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/ex_data2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/ex_data2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/ex_data2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/ex_data3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/ex_data3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/ex_data3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/ex_data3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1584/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1584/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user