首页 > 其他分享 >【考后总结】9 月 CSP-S 模拟赛 1

【考后总结】9 月 CSP-S 模拟赛 1

时间:2023-09-01 18:44:44浏览次数:51  
标签:heart 考后 int ll CSP maxn my your 模拟

9.1 CSP 模拟 32

After Hours - The Weeknd

Thought I almost died in my dream again (Baby, almost died)

Fightin' for my life, I couldn't breathe again

I'm fallin' into new (Oh, oh)

Without you goin' smooth (Fallin' in)

'Cause my heart belongs to you

I'll risk it all for you

I won't just leave

This time, I'll never leave

I wanna share babies

Protection, we won't need

Your body next to me

Is just a memory

I'm fallin' in too deep, oh

Without you, I can’t sleep

Insomnia relieve, oh

Talk to me, without you, I can't breathe

My darkest hours

Girl, I felt so alone inside of this crowded room

Different girls on the floor, distractin' my thoughts of you

I turned into the man I used to be, to be

Put myself to sleep

Just so I can get closer to you inside my dreams

Didn't wanna wake up 'less you were beside me

I just wanted to call you and say, and say

Oh, baby

Where are you now when I need you most?

I'd give it all just to hold you close

Sorry that I broke your heart, your heart

Never comin' through

I was running away from facin' reality

Wastin' all of my time on living my fantasies

Spendin' money to compensate, compensate

'Cause I want you, baby

I'll be livin' in Heaven when I'm inside of you

It was definitely a blessing, wakin' beside you

I'll never let you down again, again

Oh, baby

Where are you now when I need you most?

I'd give it all just to hold you close

Sorry that I broke your heart, your heart

I said, baby

I'll treat you better than I did before

I'll hold you down and not let you go

This time, I won't break your heart, your heart, yeah

I know it's all my fault

Made you put down your guard

I know I made you fall

I said you were wrong for me

I lied to you, I lied to you, I lied to you (To you)

Can't hide the truth, I stayed with her in spite of you

You did some things that you regret, still right for you

'Cause this house is not a home

Without my baby

Where are you now when I need you most?

I gave it all just to hold you close

Sorry that I broke your heart, your heart

And I said, baby

I'll treat you better than I did before

I'll hold you down and not let you go

This time, I won't break your heart, your heart, no

\(\text{happyguy round}\)

T1 鱿鱼

AtCoder-AGC012B Splatter Painting

注意到 \(d\) 很小,把操作按 \((u,d)\) 分组,每组只维护最后一次操作的颜色。

这样倒序枚举 \(d\),转移形如 \((u,d)\) 对 \((v,d-1)\) 产生影响,影响是关于时间取 \(\max\)。

时间复杂度 \(O(nd)\)。

点击查看代码
int n,m,q;
struct edge{
    int to,nxt;
}e[maxn<<1];
int head[maxn],cnt;
inline void add_edge(int u,int v){
    e[++cnt].to=v,e[cnt].nxt=head[u],head[u]=cnt;
    e[++cnt].to=u,e[cnt].nxt=head[v],head[v]=cnt;
}
pii OP[maxn][11];
pii ans[maxn];

int main(){
    n=read(),m=read();
    for(int i=1,u,v;i<=m;++i){
        u=read(),v=read();
        add_edge(u,v);
    }
    q=read();
    for(int i=1,u,d,c;i<=q;++i){
        u=read(),d=read(),c=read();
        OP[u][d]=make_pair(i,c);
        ans[u]=make_pair(i,c);
    }
    for(int d=10;d>=1;--d){
        for(int u=1;u<=n;++u){
            if(!OP[u][d].fir) continue;
            for(int i=head[u],v;i;i=e[i].nxt){
                v=e[i].to;
                OP[v][d-1]=max(OP[v][d-1],OP[u][d]);
                ans[v]=max(ans[v],OP[u][d]);
            }
        }
    }
    for(int i=1;i<=n;++i) printf("%d\n",ans[i].sec);
    return 0;
}

T2 球瓶

AtCoder-AGC051B Bowling

一个做法是随机三个向量 \(\vec{e_1}=(\lambda_1,0),\vec{e_2}=(\lambda_2,\lambda_2),\vec{e_3}=(0,\lambda_3)\),构造出 \(\{\vec{e}\mid \vec{e}=a\vec{e_1}+b\vec{e_2}+c\vec{e_3},1\le a,b,c\le k\}\),\(k\) 取 \(13\) 左右即可。

正确性考虑另外三个方向一定只能看到 \(k^2\) 级别的点,而最后一个方向可以看到 \(k^3\) 级别的点。

点击查看代码
vector<pii> V;
pii X,Y,Z;

int main(){
    X=make_pair(rand(1,10000),0),Y=make_pair(rand(1,10000),0),Z=make_pair(0,rand(1,10000));
    Y.sec=Y.fir;
    for(int i=1;i<=13;++i){
        for(int j=1;j<=13;++j){
            for(int k=1;k<=13;++k){
                V.push_back(make_pair(i*X.fir+j*Y.fir+k*Z.fir,i*X.sec+j*Y.sec+k*Z.sec));
            }
        }
    }
    printf("%ld\n",V.size());
    for(pii v:V) printf("%d %d\n",v.fir,v.sec);
    return 0;
}

T3 边数

原图是基环内向树。

容易发现连边都由 \(1\) 连出一定不劣,那么树的部分就是从叶子开始贪心连,设 \(f_u\) 为按照最优策略到 \(1\) \(u\) 的最短距离,这里要求 \(1\) 一定不能同环上节点增加边。

如果环上节点 \(u\) 满足 \(f_u<k\),那么还可以覆盖一些其他的节点,差分处理之后转化成环上有一些节点已经被覆盖,用若干长度为 \(k\) 的区间覆盖整个环,求最小区间个数。

特判环长不大于 \(k\) 的情况,找到环上节点 \(u\) 使得以 \(u\) 为左端点覆盖一个区间,右端点恰好之前没有被覆盖。这样覆盖这个右端点的区间的左端点一定在 \(u\) 及以后,枚举这 \(O(k)\) 个可能的左端点,后续暴力 \(O\left(\dfrac{len}{k}\right)\) 求,具体可以预处理 \(nxt_u\) 表示在环上 \(u\) 及以后的第一个之前没有被覆盖的节点,暴力跳即可。

点击查看代码
int n,k;
struct edge{
    int to,nxt;
    bool type;
}e[maxn<<1];
int head[maxn],cnt;
inline void add_edge(int u,int v){
    e[++cnt].to=v,e[cnt].nxt=head[u],e[cnt].type=true,head[u]=cnt;
    e[++cnt].to=u,e[cnt].nxt=head[v],e[cnt].type=false,head[v]=cnt;
}
int pre[maxn],tmp;
vector<int> L;
bool mark[maxn];
int dfn[maxn],dfncnt,id[maxn];
void dfs_loop(int u,int last){
    pre[u]=last;
    for(int i=head[u],v;i;i=e[i].nxt){
        v=e[i].to;
        if(i==(last^1)) continue;
        if(pre[v]){
            if(!tmp) tmp=u;
        }
        else dfs_loop(v,i);
    }
}
int dep[maxn],f[maxn],nxt[maxn];
int ans;
void dfs(int u,int d){
    dep[u]=d,f[u]=(u==1)?0:k+1;
    for(int i=head[u],v;i;i=e[i].nxt){
        if(e[i].type) continue;
        v=e[i].to;
        if(mark[v]) continue;
        dfs(v,d+1);
        f[u]=min(f[u],f[v]+1);
    }
    if(d&&f[u]==k+1) f[u]=1,++ans;
}
int sum[maxn];
inline void add(int l,int r){
    if(r<=dfncnt) ++sum[l],--sum[r+1];
    else{
        ++sum[l],--sum[dfncnt+1];
        ++sum[1],--sum[r-dfncnt+1];
    }
}

int main(){
    n=read(),k=read();
    cnt=1;
    for(int i=1,u,v;i<=n;++i){
        u=read(),v=read();
        add_edge(u,v);
    }
    for(int i=1;i<=n;++i){
        if(pre[i]) continue;
        tmp=0;
        dfs_loop(i,2*n+2);
        L.clear();
        for(int u=tmp;;){
            mark[u]=true;
            L.push_back(u);
            for(int i=head[u],v;i;i=e[i].nxt){
                if(!e[i].type) continue;
                v=e[i].to;
                u=v;
                break;
            }
            if(u==tmp) break;
        }
        dfncnt=0;
        for(int u:L) dfn[u]=++dfncnt;
        for(int u:L) dfs(u,0);
        for(int j=1;j<=dfncnt+1;++j) sum[j]=0;
        for(int u:L){
            if(f[u]!=k+1) add(dfn[u],dfn[u]+k-f[u]);
        }
        for(int j=1;j<=dfncnt;++j) sum[j]+=sum[j-1];
        if(dfncnt<k){
            bool chk=true;
            for(int j=1;j<=dfncnt;++j){
                if(!sum[j]) chk=false;
            }
            if(!chk) ++ans;
            continue;
        }
        id[1]=-1;
        for(int j=1;j<=dfncnt;++j){
            if(!sum[j+k-1>dfncnt?j+k-1-dfncnt:j+k-1]){
                for(int x=j,y=1;y<=dfncnt;++x,++y){
                    if(x>dfncnt) x=1;
                    id[y]=x;
                }
                break;
            }
        }
        if(id[1]==-1) continue;
        int last=-1;
        for(int j=dfncnt;j>=1;--j){
            if(!sum[id[j]]) last=j;
        }
        for(int j=dfncnt;j>=1;--j){
            if(!sum[id[j]]) last=j;
            nxt[j]=last;
        }
        int mn=0x3f3f3f3f;
        for(int j=1;j<=k;++j){
            int x=j,y=1,now=0;
            bool vis=false;
            while(1){
                ++now;
                x+=k,y+=k;
                if(x>dfncnt) x-=dfncnt;
                if(x<=nxt[x]) y+=nxt[x]-x;
                else y+=(dfncnt-x)+nxt[x];
                x=nxt[x];
                if(y>dfncnt) break;
            }
            mn=min(mn,now);
        }
        ans+=mn;
    }
    printf("%d\n",ans);
}

T4 假人

暴力 DP 是容易的。

结论是多重集 \(S\) 满足值域 \([0,4]\) 且元素和 \(24\),一定可以拆成两个元素和为 \(12\) 的子集。

那么 DP 过程中 \(f_{i,j+12}-f_{i,j}\ge f_{i,j+24}-f_{i,j+12}\),即一定可以先加入的贡献更大的部分,在模 \(k=12\) 的意义下转移具有凸性,可以分治再闵可夫斯基和转移,分治过程 \(O(k^2)\) 枚举左右区间模 \(k\) 的值,转移是 \(O\left(\dfrac{n}{k}\right)\),总复杂度是 \(O(kn\log n)\)。

点击查看代码
int n;
int a[maxn][6],sumk[maxn];

vector<ll> Minkowski(vector<ll> f,vector<ll> g){
    vector<ll> a,b,h;
    for(int i=1;i<f.size();++i) a.push_back(f[i]-f[i-1]);
    for(int i=1;i<g.size();++i) b.push_back(g[i]-g[i-1]);
    h.resize(f.size()+g.size()-1);
    merge(a.begin(),a.end(),b.begin(),b.end(),h.begin()+1,greater<ll>());
    h[0]=f[0]+g[0];
    for(int i=1;i<h.size();++i) h[i]+=h[i-1];
    return h;
}

#define mid ((l+r)>>1)
vector<vector<ll>> solve(int l,int r){
    vector<vector<ll>> res;
    res.resize(12);
    if(l==r){
        for(int i=0;i<a[l][5];++i) res[i].push_back(a[l][i]);
        return res;
    }
    vector<vector<ll>> f,g;
    vector<ll> h;
    f=solve(l,mid),g=solve(mid+1,r);
    for(int i=0;i<12;++i) res[i].resize((sumk[r]-sumk[l-1])/12+(i<=((sumk[r]-sumk[l-1])%12)));
    for(int i=0;i<12;++i){
        for(int j=0;j<12;++j){
            if(!f[i].size()||!g[j].size()) continue;
            h=Minkowski(f[i],g[j]);
            if(i+j<12){
                for(int k=0;k<h.size();++k){
                    res[(i+j)%12][k]=max(res[(i+j)%12][k],h[k]);
                }
            }
            else{
                for(int k=0;k<h.size();++k){
                    res[(i+j)%12][k+1]=max(res[(i+j)%12][k+1],h[k]);
                }
            }
        }
    }
    return res;
}
#undef mid

int main(){
    n=read();
    for(int i=1;i<=n;++i){
        a[i][5]=read();
        sumk[i]=sumk[i-1]+a[i][5]-1;
        for(int j=0;j<a[i][5];++j){
            a[i][j]=read();
        }
    }
    vector<vector<ll>> ans=solve(1,n);
    for(int i=0;i<=sumk[n];++i){
        printf("%lld ",ans[i%12][i/12]);
    }
    printf("\n");
    return 0;
}

标签:heart,考后,int,ll,CSP,maxn,my,your,模拟
From: https://www.cnblogs.com/SoyTony/p/Simulation_Problems_of_CSP-S_in_September_1.html

相关文章

  • 如何让文本模拟打字效果出现
    最近在做一个chatGpt聊天页面,需要把后端返回的文本以打字的效果输出。一开始想着是利用CSS的动画效果来实现。实现方式如下:<html><head><title>Typing</title></head><style>body{background:navajowhite;background-size:cover;font-family:'Treb......
  • 2023西安/成都/深圳CSPM-3国标项目管理含金量真高,太值了
    CSPM-3中级项目管理专业人员评价,是中国标准化协会(全国项目管理标准化技术委员会秘书处),面向社会开展项目管理专业人员能力的等级证书。旨在构建多层次从业人员培养培训体系,建立健全人才职业能力评价和激励机制的要求,培养我国项目管理领域复合型人才。  【证书含金量】 ·竞聘优先......
  • MindSponge分子动力学模拟——定义一个分子系统(2023.08)
    技术背景在前面两篇文章中,我们分别介绍了分子动力学模拟软件MindSponge的软件架构和安装与使用教程。这里我们进入到实用化阶段,假定大家都已经在本地部署好了基于MindSpore的MindSponge的编程环境,开始用MindSponge去做一些真正的分子模拟的工作。那么分子模拟的第一步,我们就需要......
  • CSP2022 游记
    2022.6.?报名。2022.7.?缴费,是来捐款的。2022.8.31隔天开学了,很慌,初赛一直都只是看知识点,没有练题。2022.9.1~2022.9.15一直在练题,不过没怎么练阅读程序和完善程序,摆。2022.9.1?我爸又跟我吵了一架,他总是在支持与不支持直接来回跳跃,然后班主任出马,他转变成了支持。2022.9......
  • 20230802模拟赛
    20230802模拟赛T1数学题题意令\(A,B,C\)为三个质数(\(A\leqB\leqC\)),\(N=A\timesB\timesC\)。给出\(N(1\leqN\leq10^{14})\),求\(B\)。题解由\(A\leqB\leqC\)可证复杂度直接枚举\(1e7\)个质数,求\(B\)。T2子序列题意给定一个长度为\(n(\leq35)\)的序列:......
  • 模拟集成电路设计系列博客——1.3.2 增益提升
    1.3.2增益提升之前在电流镜章节提到过应用放大器来增加电流镜输出阻抗,同样的技术被用于增加Cascode增益级的输出阻抗,如下图所示:其增益由下式给出:\[A_v(s)=\frac{V_{out}(s)}{V_{in}(s)}=-g_{m2}(R_{out}(s)||\frac{1}{sC_L})\tag{1.3.20}\]其中\(R_{out}(s)\)由下式给出:\[......
  • 模拟实现一个简单的计算器
    voidmenu(){ printf("**********************\n"); printf("****1.Add2.Sub****\n"); printf("****3.Mlu4.Del****\n"); printf("*****0.exit****\n"); printf("**********************\n");}......
  • strstr函数及其代码模拟实现
    一.用法定义:char*strstr(constchar*str1,constchar*str2);•判断str1中是否包含子串str2•若包含,则返回在str1中子串str2首字符的地址•若不包含,则返回空指针NULL例:#define_CRT_SECURE_NO_WARNINGS1#include<stdio.h>#include<string.h>intmain(){ chararr1[]=......
  • Python爬虫实战 - 模拟登录采集数据
    在进行数据采集时,有些网站需要进行登录才能获取到所需的数据。本文将介绍如何使用Python爬虫进行模拟登录,以便采集网站的数据。我们提供了完善的方案和代码示例,让你能够轻松操作并获取所需的数据。使用Python爬虫模拟登录网站采集数据价值:数据获取:通过模拟登录,你可以通过网站的登录......
  • Unity RenderTexture 当作为 Camera.targetTexture 时,在某些安卓手机或模拟器无法显示
    今天打包的时候遇到一个坑,就是用RenderTexture的时候,在某些手机上会显示黑屏,一查发现这是某些安卓设备才会出现的BUG(奇怪的是那台测试机是鸿蒙系统,懂的都懂)解决方法也很简单,就是不能用RenderTexture资源,而改成动态代码创建即可解决这个BUG同时解决了另一个RenderTexture的BUG,就......