9.17 simulated match

Posted yodel

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了9.17 simulated match相关的知识,希望对你有一定的参考价值。

 

 

#include<cstdio>
#define init(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout); 
#define fr(i,a,b)  for(int i=a;i<=b;i++)
#define g()  getchar()
using namespace std;
int read(){int x=0,f=1;char c=g();
    for(;c<\'0\'||c>\'9\';c=g())if(c==\'-\')f=-1;
    for(;\'0\'<=c&&c<=\'9\';c=g())x=(x<<3)+(x<<1)+(c^48);return x*f;}
#define swap(x,y)    x^=y,y^=x,x^=y
#define maxn  50005
#define maxm  1000005
int n,size,tp,ans[maxm],pos[maxn],stk[maxm];
int main(){init("tet");n=read();
    fr(i,1,n<<1){int x=read();stk[++tp]=x;
        if(pos[x]){
            if(pos[x]==tp-1){tp-=2;continue;}
            int t=pos[x];
            while(t!=tp-1)swap(stk[t],stk[t+1]),pos[stk[t]]--,ans[++size]=t++;
            tp-=2;pos[x]=0;}else pos[x]=tp;}
    printf("%d\\n",size);fr(i,1,size)printf("%d\\n",ans[i]);return 0;
}

well,the code is the best language.

 


 

 

 

 

 

#include <bits/stdc++.h>
#define init(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout); 
#define H  (long long)tmp*tmp/y
#define fr(a,b,c)  for(a=b;a<=c;a++)
using namespace std;
char ch[500005];int n,len,ans,i;long long tmp;
vector<pair<int,int> >V;
inline void add(int x){int t;V.clear();
    fr(i,2,sqrt(x))if(x%i==0){t=0;
        while(x%i==0)t+=2,x/=i;
        V.push_back(make_pair(i,t));}
    if(x>1)V.push_back(make_pair(x,2));
}
void dfs(int x,long long y){
    if(x>=len){if(H<=n&&(ch[y]==\'a\'&&ch[H]==\'c\'||ch[y]==\'c\'&&ch[H]==\'a\'))ans++;return;}
    dfs(x+1,y);int i;
    fr(i,1,V[x].second){y*=V[x].first;if(y>=tmp)break;dfs(x+1,y);}
}
int main(){init("find");scanf("%d%s",&n,ch+1);
    fr(tmp,2,n-1)
    if(ch[tmp]==\'b\')add(tmp),len=V.size(),dfs(0,1);
    printf("%d",ans);return 0;             
}

well,the code is the best language

 


 

 

 

 

#include <cstdio>
#define ll long long
#define bg(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout); 
#define MOD 1000000007
#define cint    register int
#define fr(a,b,c,d) for(cint a=b;a-d!=c;a+=d)
using namespace std;
int n,m,opt,A,B,C,cnt[11][11];
struct node{ll v[11],tagt,tagn;
    void init(int x){v[0]=1;fr(i,1,10,1)v[i]=v[i-1]*x%MOD;}
    void add(int x){int tv,r;
        fr(i,10,0,-1){tv=0,r=1;
            fr(j,i,0,-1)tv=(v[j]*cnt[i][j]%MOD*r+tv)%MOD,r=(ll)r*x%MOD;
            v[i]=tv;}}}tr[400005];
#define g()  getchar()
using namespace std;
int read(){int x=0,f=1;char c=g();
    for(;c<\'0\'||c>\'9\';c=g())if(c==\'-\')f=-1;
    for(;\'0\'<=c&&c<=\'9\';c=g())x=(x<<3)+(x<<1)+(c^48);return x*f;}
inline int DEC(int x){return x>=MOD?x-MOD:x;}
void pushup(int x){int ls=x<<1,rs=x<<1|1;
    for(int i=0;i<=10;i++)tr[x].v[i]=DEC(tr[ls].v[i]+tr[rs].v[i]);}
void downpush(int k,int l,int r){int ls=k<<1,rs=k<<1|1,mid=(l+r)>>1;
    if (tr[k].tagt==1){
        if(!tr[ls].tagt) tr[ls].tagt=1;if(!tr[rs].tagt)tr[rs].tagt=1;
        tr[ls].tagn+=tr[k].tagn,tr[rs].tagn+=tr[k].tagn;
        tr[ls].add(tr[k].tagn),tr[rs].add(tr[k].tagn);}
    else if(tr[k].tagt==2){
        tr[ls].tagt=tr[rs].tagt=2;
        tr[ls].tagn=tr[rs].tagn=tr[k].tagn;
        tr[ls].init(tr[k].tagn);tr[rs].init(tr[k].tagn);
        for(int i=0;i<=10;i++)
            tr[ls].v[i]=tr[ls].v[i]*(mid-l+1)%MOD,tr[rs].v[i]=tr[rs].v[i]*(r-mid)%MOD;
    }tr[k].tagt=tr[k].tagn=0;}
void build(int k,int l,int r){if(l==r){tr[k].init(read());return;}
    int mid=(l+r)>>1;build(k<<1,l,mid);build(k<<1|1,mid+1,r);pushup(k);}
void update_add(int k,int l,int r,int a,int b,int x){
    if(a<=l&&r<=b){if(!tr[k].tagt)tr[k].tagt=1;
        tr[k].tagn+=x;tr[k].add(x);return;}
    if(tr[k].tagt)downpush(k,l,r);
    int mid=(l+r)>>1;
    if(a<=mid)update_add(k<<1,l,mid,a,b,x);
    if(mid<b)update_add(k<<1|1,mid+1,r,a,b,x);pushup(k);}
void update_mod(int k,int l,int r,int a,int b,int x){
    if(a<=l&&r<=b){tr[k].tagt=2;tr[k].tagn=x;tr[k].init(x);
        fr(i,0,10,1)tr[k].v[i]=tr[k].v[i]*(r-l+1)%MOD;return;}
    if(tr[k].tagt)downpush(k,l,r);int mid=(l+r)>>1;
    if(a<=mid)update_mod(k<<1,l,mid,a,b,x);
    if(mid<b)update_mod(k<<1|1,mid+1,r,a,b,x);pushup(k);}
int query(int k,int l,int r,int a,int b,int x)
{if(r<a||l>b)return 0;if(a<=l&&r<=b)return tr[k].v[x];
    if(tr[k].tagt) downpush(k,l,r);int mid=(l+r)>>1;
    return DEC(query(k<<1,l,mid,a,b,x)+query(k<<1|1,mid+1,r,a,b,x));}
int main(){bg("boat");
    cnt[0][0]=1;
    fr(i,1,10,1){cnt[i][0]=1;fr(j,1,i,1)cnt[i][j]=cnt[i-1][j-1]+cnt[i-1][j];}
    n=read(),m=read();build(1,1,n);
    fr(i,1,m,1){opt=read(),A=read(),B=read(),C=read();
        switch (opt){
            case 1:update_add(1,1,n,A,B,C);break;
            case 2:update_mod(1,1,n,A,B,C);break;
            case 3:printf("%d\\n",query(1,1,n,A,B,C));break;}}
    return 0;
}

well,the code is the best language.

以上是关于9.17 simulated match的主要内容,如果未能解决你的问题,请参考以下文章

9.24 simulated match

10.5 simulated match

10.22 simulated match

10.27 simulated match

9.10 simulated match

9.17homework