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) {} | |
}; |
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") | |
#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
#include <bits/stdc++.h> | |
using namespace std; | |
int N, Q, t, l, r; long x; | |
struct node { | |
long a, b, m, n; | |
void input() { cin>>a; m=n=a; } | |
node operator+(node& R) { | |
return {a+R.a, 0, max(m, R.m), min(n, R.n)}; | |
} |
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
// LEETCODE | |
#include <bits/stdc++.h> | |
namespace leetcode { | |
#define __COUT_DEFAULT_DELIMITER__ "," | |
// #define __PARSE_INT128__ | |
// #define __PARSE_CHAR_QUOTE__ '\' | |
// #define __PARSE_STRING_DELIMITER__ " ,]})" | |
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
// int rank[N]; vector<int> G[N]; | |
auto rank_tree(int i, int p=-1) { | |
int x=0, y=0; | |
for(int j:G[i]) if(j!=p) { | |
auto z=rank_tree(j, i); | |
y|=x&z, x|=z; | |
} | |
x=(x|(1<<31-__builtin_clz(y<<1|1))-1)+1; | |
rank[i]=__builtin_ctz(x); | |
return x; |
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
#include <bits/stdc++.h> | |
using namespace std; | |
using ll=long long; | |
constexpr int MXN=1e5; | |
int A[MXN], B[MXN], N; | |
ll D[MXN]; | |
ll f(int j, int i) { return D[j] + 1LL*A[i]*B[j]; } | |
bool cmp(int i, int j, int x) { return f(i, x)<f(j, x); } |
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
template<class T=int, class O=less<T>> | |
struct heap_set { | |
priority_queue<T, vector<T>, O> q, del; | |
const T& top() const { return q.top(); } | |
int size() const { return int(q.size()-del.size()); } | |
bool empty() const { return !size(); } | |
void flush() { while(del.size() && q.top()==del.top()) q.pop(), del.pop(); } | |
void insert(const T x) { q.push(x); flush(); } | |
void pop() { q.pop(); flush(); } | |
void erase(const T x) { del.push(x); flush(); } |
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
namespace io { | |
const signed IS=1<<22; | |
char I[IS+1],*J=I; | |
inline void daer(){char*p=I;while(*J)*p++=*J++;p[fread(p,1,I+IS-p,stdin)]=0;J=I;} | |
template<int N=10,typename T=int>inline T getu(){if(J>=I+IS-64)daer();T x=0;int k=0;do x=x*10+(*J-'0');while(*++J>='0'&&++k<N);++J;return x;} | |
struct f{f(){I[fread(I,1,IS,stdin)]=0;}}flu; | |
}; | |
using namespace io; |
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("avx2") | |
#include <bits/stdc++.h> | |
#define R(i,n) for(int i=0; i<n; i++) | |
using namespace std; | |
int main() { | |
ios::sync_with_stdio(0);cin.tie(0); | |
int N, Q; | |
cin>>N>>Q; | |
alignas(32) long X[2048]; |
OlderNewer