# 代码

/**************************************************************    Problem: 4539    User: 941822900    Language: C++    Result: Accepted    Time:16364 ms    Memory:84644 kb****************************************************************/#include<bits/stdc++.h>#define ll long longusing namespace std;const int maxn=100000+10;vector<int> G[maxn];int n,m,q;ll N=1;int f1[maxn][20],f2[maxn][20];int dep1[maxn],dep2[maxn];ll dtr[maxn];#define lc ch[o][0]#define rc ch[o][1]#define mid ((l+r)>>1)int num;int root[maxn];int sumv[maxn*50];int ch[maxn*50][2];void add(int o,int l,int r,int x){    if(l==r) ++sumv[o];    else{        if(x<=mid){            if(!lc) lc=++num;            add(lc,l,mid,x);        }        else{            

# 代码

/**************************************************************    Problem: 1566    User: 941822900    Language: C++    Result: Accepted    Time:7148 ms    Memory:3280 kb****************************************************************/#include<bits/stdc++.h>using namespace std;const int maxn=505;const int p=1024523;int n,m,ans,cur;char a[maxn],b[maxn];int f[2][maxn][maxn];int main(){    f[cur][0][0]=1;    scanf("%d%d",&n,&m);    scanf("%s%s",a+1,b+1);    for(int i=1;i<=(n>>1);i++) swap(a[i],a[n-i+1]);    for(int i=1;i<=(m>>1);i++) swap(b[i],b[m-i+1]);    for(int i=1;i<=n+m;i++){        cur^=1;        memset(f[cur],0,sizeof(f[cur]));        for(int j=0;j<=i&&j<=n;j++)            for(int k=0;k<=i&&k<=n;k++)                if(i-j<=m&&i-k<=m){                    if(b[i-j]==b[i-k]) f[cur][j][k]+=f[

bzoj上数据范围都不给...

# 代码

/**************************************************************    Problem: 1564    User: 941822900    Language: C++    Result: Accepted    Time:200 ms    Memory:2940 kb****************************************************************/#include<bits/stdc++.h>using namespace std;const int maxn=75;int n,K,ans,pre[maxn],f[maxn][maxn][maxn];struct node{    int a,b,c;    node(){}    node(int a,int b,int c):a(a),b(b),c(c){}}p[maxn];bool cmpa(const node& p1,const node& p2){    return p1.a<p2.a;}bool cmpb(const node& p1,const node& p2){    return p1.b<

# 代码

/**************************************************************    Problem: 2286    User: 941822900    Language: C++    Result: Accepted    Time:12912 ms    Memory:61976 kb****************************************************************/#include<bits/stdc++.h>#define ll long longusi

# 代码

/**************************************************************    Problem: 3110    User: 941822900    Language: C++    Result: Accepted    Time:8188 ms    Memory:12236 kb****************************************************************/#include<bits/stdc++.h>#define int long long#define getchar getchar_unlocked#define putchar putchar_unlockedusing namespace std;const int maxn=50000+10;void read(int& ret){    char c;ret=0;bool fu=false;    while((c=getchar()),(c<'0'||c>'9'))        fu=c=='-';    do (ret*=10)+=c-'0';    while((c=getchar()),(c>='0'&&c<='9'));    if(fu) ret=-ret;}struct query{    int t,ans;    int k,a,b,c;    void Read(){        read(k);read(a);        read(b);read(c);    }    bool operator < (const qu

# 题解

1.lca是圆点,则dis=dep[u]+dep[v]-dep[lca]*2
2.lca是方点,则dis=u到环的距离+v到环的距离+u,v到环上那两点的距离
1直接倍增，2先倍增，再考虑什么map之类的东西记一记。

# 代码

/**************************************************************    Problem: 2125    User: 941822900    Language: C++    Result: Accepted    Time:604 ms    Memory:5176 kb****************************************************************/#include<bits/stdc++.h>using namespace std;const int maxn=10000+10;vector<int> G[maxn][2];int n,m,q,tot=2,first[maxn*2];int to[maxn*4],dis[maxn*4],next[maxn*4];int num,sz,fa[maxn],z[maxn],dfn[maxn],low[maxn];void addedge(int u,int v,int w){    to[tot]=v;    dis[tot]=w;    next[tot]=first[

dp+单调队列即可。

# 代码

/**************************************************************    Problem: 1023    User: 941822900    Language: C++    Result: Accepted    Time:444 ms    Memory:7536 kb****************************************************************/#include<bits/stdc++.h>using namespace std;const int inf=2e9;const int maxn=50000+10;vector<int> G[maxn];int fa[maxn],dep[maxn];int top,stk[maxn],a[maxn*2];int num,dfn[maxn],low[maxn];int n,m,ans,f[maxn],q[maxn*2];void dp(int u,int v){    int tot=dep[v]-dep[u]+1;    for(int i=v;i!=u;i=fa[i])        a[tot--]=f[i];    a[tot]=f[u];    tot=dep[v]-dep[u]+1;    for(int i=tot+1;i<=tot*2;i++)        a[i]=a[i-tot];    int l=1,r=0;    for(int i=2;i<=tot*2;i++){        if(l<=r&&i-q[l]>tot/2)            ++l;        if(l<=r)            ans=max(ans,i+a[i]-q[l]+a[q[l]]);        while(l<=r&&a[q[r]]-q[r]<a[i]-i)            --

# 代码

#include<bits/stdc++.h>using namespace std;const int maxn=500+10;int nl,nr,m,ans,l[maxn];bool vis[maxn],s[maxn][maxn];bool match(int u){    for(int v=1;v<=nl;v++)        if(s[u][v]&&!vis[v]){            vis[v]=true;            if(!l[v]||match(l[v])){                l[v]=u;                return true;            }        }    return false;}int main(){    cin>>nl>>nr>>m;    for(int i=1;i<=m;i++){        int u,v;        scanf("%d%d",&u,&v);        s[v][u]=true;    }    for(int i=1;i<=nr;i++){        ans+=match(i);        memset(vis,false,sizeof(vis));    }    cout<<ans<<endl;    for(int i=1;i<=nl;i++)        printf("%d ",l[i]);    return 0;}
1/5