Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define _ ios_base::sync_with_stdio(0);cin.tie(0);
- #define endl '\n'
- #define sc(a) scanf("%d",&a)
- #define sc2(a,b) sc(a), sc(b)
- #define pri(x) printf("%d\n",x)
- #define f first
- #define s second
- #define pb push_back
- typedef long long ll;
- typedef pair<int, int> ii;
- const int INF = 0x3f3f3f3f;
- const ll LINF = 0x3f3f3f3f3f3f3f3fll;
- const int D = 2;
- const int MAX = 100;
- int n;
- vector<ll> bit[1<<D];
- void build() {
- int sz = 1;
- for (int i = 0; i < D; i++) sz *= MAX;
- for (int i = 0; i < (1<<D); i++)
- bit[i] = vector<ll>(sz+10, 0);
- }
- void updatep(int i, vector<int>& p, ll k, int it=0) {
- if (it == D) {
- int pos = 0, power = 1;
- for (int i = 0; i < p.size(); i++) {
- pos += p[i]*power;
- power *= n;
- }
- bit[i][pos] += k;
- return;
- }
- for (int x = p[it]; x <= n; x += x&-x) {
- int tmp = p[it]; p[it] = x;
- updatep(i, p, k, it+1);
- p[it] = tmp;
- }
- }
- void updater(int i, vector<int>& p1, vector<int> & p2, ll k) {
- for (int i = 0; i < (1<<D); i++) {
- vector<int> P;
- for (int j = 0; j < D; j++)
- P.push_back((i&(1<<j)) ? p1[j] : p2[j]+1);
- updatep(i, P, (__builtin_popcount(i)%2) ? -k : k);
- }
- }
- ll queryp(int i, vector<int>& p, int it=0) {
- if (it == D) {
- int pos = 0, power = 1;
- for (int i = 0; i < p.size(); i++) {
- pos += p[i]*power;
- power *= n;
- }
- return bit[i][pos];
- }
- ll ans = 0;
- for (int x = p[it]; x; x -= x&-x) {
- int tmp = p[it]; p[it] = x;
- ans += queryp(i, p, k, it+1);
- p[it] = tmp;
- }
- return ans;
- }
- void update(vector<int>& p1, vector<int>& p2, ll k) {
- for (int i = 0; i < (1<<D); i++) {
- for (int j = 0; j < (1<<__builtin_popcount(i)); j++) {
- vector<pt> P1, P2; ll K = k;
- for (int jj = 0; jj < D; jj++) {
- P1.push_back((j&(1<<jj)) ? p2[j]+1 : p1[j]);
- P2.push_back((j&(1<<jj)) ? n : p2[j])
- K *= ((j&(1<<jj)) ? p2[j]-p1[j]+1 : p1[j]-1)
- }
- updater(i, P1, P2, (__builtin_popcount(j)%2) ? -k : k);
- }
- }
- }
- ll queryP(vector<int>& p) {
- ll ans = 0;
- for (int i = 0; i < (1<<D); i++) {
- ll x = queryp(i, p1);
- for (int j = 0; j < D; j++) if (!(i&(1<<j))) x *= p[j];
- ans += x;
- }
- return ans;
- }
- ll query(vector<int>& p1, vector<int>& p2) {
- ll ans = 0;
- for (int i = 0; i < (1<<D); i++) {
- vector<int> P;
- for (int j = 0; j < D; j++)
- P.push_back((i&(1<<j)) ? p1[j]-1 : p2[j]);
- ll add = queryP(P);
- ans += (__builtin_popcount(i)%2) ? -add : add;
- }
- return ans;
- }
- int main() {
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement