
C++char buf[1 << 23] , * p1 = buf , * p2 = buf , obuf[1 << 23] , * O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline int read() {
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9')x=x*10+ch-48,ch=getchar();
return x*f;
}
inline void write(int x){
if(x<0)putchar('-'),x*=-1;
if(x>9)write(x/10);
putchar('0'+x%10);
}
代码cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
C++//线段树主要操作
int ls(int p) {
return p<<1;
}
int rs(int p) {
return p<<1|1;
}
void push_up(int p) {
tree[p]=tree[ls(p)]+tree[rs(p)];
}
void build(int p,int pl,int pr) {
taga[p]=0;
if(pl==pr) {
tree[p]=a[pl];
return;
}
int mid=(pl+pr)>>1;
build(ls(p),pl,mid);
build(rs(p),mid+1,pr);
push_up(p);
}
void addtag(int p,int pl,int pr,int d) {
taga[p]+=d;
tree[p]+=(pr-pl+1)*d;
}
void push_down(int p,int pl,int pr) {
if(taga[p]) {
int mid = (pl+pr)>>1;
addtag(ls(p),pl,mid,taga[p]);
addtag(rs(p),mid+1,pr,taga[p]);
taga[p]=0;
}
}
void update(int l,int r,int p,int pl,int pr,int d) {
if(l<=pl&&pr<=r) {
addtag(p,pl,pr,d);
return;
}
push_down(p,pl,pr);
int mid=(pl+pr)>>1;
if(l<=mid)update(l,r,ls(p),pl,mid,d);
if(r>mid)update(l,r,rs(p),mid+1,pr,d);
push_up(p);
}
int query(int l,int r,int p,int pl,int pr) {
if(l<=pl&&pr<=r)return tree[p];
push_down(p,pl,pr);
int res=0;
int mid=(pl+pr)>>1;
if(l<=mid)res+=query(l,r,ls(p),pl,mid);
if(r>mid)res+=query(l,r,rs(p),mid+1,pr);
return res;
}
C++#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
int n,m,tree[N];
void update(int x,int d) {
while(x<=n) {
tree[x]+=d;
x+=lowbit(x);
}
}
int sum(int x) {
int ans=0;
while(x>0) {
ans+=tree[x];
x-=lowbit(x);
}
return ans;
}
inline int read() {
int x=0,f=1;
char ch=getchar();
while (ch<'0'||ch>'9') {
if (ch=='-') f=-1;
ch=getchar();
}
while (ch>='0'&&ch<='9') {
x=x*10+ch-48;
ch=getchar();
}
return x*f;
}
int main(){
return 0;
}
卜卦
哲理金句
KMP
DP背包
尺取法1
尺取法2(知乎)
尺取法3(有例题)
尺取法4(last)
悬线法
刷新
oi-wiki.org
ACwing
CSDN
信息奥赛学校排名
C++#define getchar() gc()
#define putchar(x) pc(x)
const int BUF_SIZE=10000;
static char buf[BUF_SIZE], *p11 = buf, *p2 = buf, obuf[BUF_SIZE], *p3 = obuf;
inline void fls() {
fwrite(obuf, p3 - obuf, 1, stdout), p3 = obuf;
}
inline char gc() {
return p11 == p2 && (p2 = (p11 = buf) + fread(buf, 1, BUF_SIZE, stdin), p11 == p2) ? EOF: *p11++;
}
inline void pc(char x) {
if (p3 - obuf >= BUF_SIZE) fls();
*p3++ = x;
}
inline int fr() {
int x = 0;
char ch = getchar(), sign = '+';
while (!isdigit(ch)) sign = ch, ch = getchar();
do x = x * 10 + (ch ^ 48), ch = getchar();
while (isdigit(ch));
return sign == '-' ? -x : x;
}
inline void write(int x, char l = '\n') {
if (x) {
char n[20];
int cnt = 0;
if (x < 0) putchar('-'), x = -x;
do n[cnt++] = x % 10 ^ 48, x /= 10;
while (x);
do putchar(n[--cnt]);
while (cnt);
} else
putchar('0');
putchar(l);
}