比赛 |
Asm.Def战记之圣地亚哥“杯2015 |
评测结果 |
AAAAAAAWWW |
题目名称 |
Asm.Def的命令 |
最终得分 |
70 |
用户昵称 |
djj |
运行时间 |
0.437 s |
代码语言 |
C++ |
内存使用 |
14.42 MiB |
提交时间 |
2019-10-23 18:07:47 |
显示代码纯文本
#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 ();
}