记录编号 |
544879 |
评测结果 |
AAAAAAAWWW |
题目名称 |
[SYOI 2015] Asm.Def的命令 |
最终得分 |
70 |
用户昵称 |
djj |
是否通过 |
未通过 |
代码语言 |
C++ |
运行时间 |
0.446 s |
提交时间 |
2019-10-23 19:38:22 |
内存使用 |
14.42 MiB |
显示代码纯文本
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
const int maxn = 1e5 + 10;
inline int read() {
char c = getchar(); int x = 0, f = 1;
for (; c > '9' || c < '0'; c = getchar()) if (c == '-') f = -1;
for (; c >='0' && c <='9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
return x * f;
}
int n, m;
struct djj_lxy_Tree {
int z[maxn];
void add (int i, int x) {
for (; i <= n; i += i & -i)
z[i] += x;
}
void change (int l, int r, int x) {
add (l, x), add (r + 1, -x);
}
int ask (int i) {
int ans = 0;
for (; i; i -= i & -i)
ans += z[i];
return ans;
}
} tx, ty;
void change () {
int l = read(), r = read();
int x = read(), y = read();
tx.change (l, r, x);
ty.change (l, r, y);
}
void query () {
int i = read();
int x = tx.ask (i);
int y = ty.ask (i);
printf ("%.1lf %.1lf\n", (double)x, (double)y);
}
void djj_lxy () {
n = read(), m = read();
for (register int i = 1; i <= n; i ++)
ty.add (i, 1);
for (; m; m --) {
int das = read();
if (das == 1) change ();
else query ();
}
}
int main () {
freopen ("asm_command.in", "r", stdin);
freopen ("asm_command.out", "w", stdout);
djj_lxy ();
}