hiho week 172 register

Ended

Participants:329

Verdict:Accepted
Score:100 / 100
Submitted:2017-10-14 23:50:00

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
using namespace std;
int s[1025][1025];
char op[4];
int mod = 1e9 + 7;
inline int sum(int x, int y){
    int ret = 0;
    for (int i = x; i > 0; i -= (i&-i))
    for (int j = y; j > 0; j -= (j&-j)){
        (ret += s[i][j]) %= mod;
    }
    return ret;
}
int main(){
    int n, m;
    cin >> n >> m;
    for (int k = 0; k < m; k++){
        scanf("%s", op);
        if (op[0] == 'A') {
            int x, y, v;
            scanf("%d%d%d", &x, &y, &v);
            x++, y++;
            for (int i = x; i <= n; i += (i&-i))
                for (int j = y; j <= n; j += (j&-j)){
                    (s[i][j] += v) %= mod;
                }
        } else {
            int x1, y1, x2, y2, s1, s2, s3, s4;
            scanf("%d%d%d%d", &x1, &y1, &x2,&y2);
            x1++, y1++, x2++, y2++;
            s1 = sum(x2, y2);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX