This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma GCC optimize("O3") | |
#include <bits/stdc++.h> | |
using namespace std; | |
using ll=long long; | |
constexpr int LG=32-__builtin_clz(200000-1); | |
constexpr ll MX=4e18; | |
int N, M, Q, t, l, r; ll x; | |
struct node { | |
ll sum, lz, mx, mx2, mn, mn2; int mxc, mnc; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* struct node { ... }; */ | |
int N; | |
node A[1<<LG_SZ]; | |
void qry(int s=0, int e=N-1, int i=1) { | |
if(l<=s && e<=r && A[i].apply(e-s+1)) return; | |
int m=s+e>>1; | |
A[i*2].down(A[i], m-s+1); | |
A[i*2+1].down(A[i], e-m); | |
if(l<=m) qry(s, m, i*2); | |
if(r>m) qry(m+1, e, i*2+1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma GCC optimize("O3") | |
#pragma GCC target("avx,avx2,fma") | |
#include <cstdio> | |
#include <algorithm> | |
#include <x86intrin.h> | |
// https://arxiv.org/ftp/arxiv/papers/1407/1407.3383.pdf | |
struct Mod { | |
int m, s, n; | |
constexpr Mod(int const MOD): m(MOD), s(std::__lg(std::max(m, 4u)-1)-1), n((1ULL<<s+33)/m) {} | |
}; |
NewerOlder