题目链接: D. Vanya and Treasure time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input output standard output Vanya is in the palace that can be represented as a grid n × m. Each room contains a single chest, an the room…
Codeforces 题目传送门 & 洛谷题目传送门 一道难度 *3100 的 DS,而且被我自己搞出来了! 不过我终究还是技不如人,因为这是一个 \(n\log^2n\) + 大常数的辣鸡做法,几乎是卡着时空限制过去的-- 首先注意到对于每个小马,在任意时刻它的法力值只有三种可能: \(s_i+kr_i(k\in\mathbb{Z})\) \(kr_i(k\in\mathbb{Z})\) \(m_i\) 我们考虑对这三种情况一一分析,对于第一种情况这里的 \(k\) 只可能等于我们待查询的 \…
今天练习赛的题....又是线段树的变换..拿到题我就敲了个点更新区间查询的..果断超时...然后想到了可以将每个数与合表示成不进位的二进制数..这样就可以区间进行更新了..比赛的时候写搓了..刚重写了一遍过~~ 为了表示每位的二进制数...线段树开成二维的...第一维老样子~记是树中哪个点..第二维记当前段之和的不进位二进制数...因为最多到10^5...也就是不会超过2^20...第二维开个20就够了.... 区间更新如:   3 3    这段全xor 3...3+3的不进位二进制数为(2,…
                                                                                       E. XOR on Segment You've got an array a, consisting of n integers a1, a2, ..., an. You are allowed to perform two operations on this array: Calculate the sum of cu…
[链接]我是链接 [题意] 接上一篇文章 [题解] 接(点我进入)上一篇文章. 这里讲一种用类似二维线段树的方法求矩形区域内点的个数的方法. 我们可以把n个正方形用n棵线段树来维护. 第i棵线段树维护的是正方形的前i列的各行之间的点数之和. 也即前i列,第[x..y]行之间点的个数(也即一个(y-x+1)*i的矩形区域的点的个数); 因为每一列只有一个点. 所以,我们在输入的时候,当前的"行区间l..r"的点数和,直接加上1就好. 然后看看输入的点所在的行区间在l..m还是m+1..r…
题目大意: 就是在二维的空间内进行单个的修改,或者进行整块矩形区域的最大最小值查询 二维线段树树,要注意的是第一维上不是叶子形成的第二维线段树和叶子形成的第二维线段树要  不同的处理方式,非叶子形成的线段树总是在自身的叶子处不能直接更新数据,而是要以一维下他的左右孩子对应的位置数据进行更新. #include <bits/stdc++.h> using namespace std; #define N 505 #define ls o<<1 #define rs o<<…
题目链接 二维树状数组 #include<iostream> #include<math.h> #include<algorithm> #include<stdlib.h> using namespace std; #define ll long long #define re(i,n) for(int i=0;i<n;i++) ; int c[maxn][maxn]; int n, q; int lowbit(int x){ return x&…
之前只知道这个东西的大概概念,没具体去写,最近呵呵,今补上. 二维线段树 -- 点更段查 #include <cstdio> #include <cstring> #include <iostream> using namespace std; int N,M; double ma[110<<2][1010<<2]; void pushUpY(int xu,int u){ ma[xu][u]=max(ma[xu][u<<1], ma[…
Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 17880   Accepted: 6709 Description Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1…
Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 14391   Accepted: 6685 Description Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is divided into squares. The…