Xyl 的何意味挑战赛#28 题解
2026-02-22 22:32:56
发布于:广东
个人评级:红红红红黄橙
口胡评级:蓝蓝灰蓝蓝紫
T1:模拟。NoonMaple 只会出模拟。
口胡一下,由于是区间交换很明显是平衡树,蓝。
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define mid (ql+qr>>1)
#define enter putchar_unlocked('\n')
il int read(){
re int x=0,f=1,ch=getchar_unlocked();
for(;!isdigit(ch);ch=getchar_unlocked())if(ch=='-')f=-1;
for(;isdigit(ch);ch=getchar_unlocked())x=(x<<3)+(x<<1)+(ch^48);
return x*f;
}
il void write(long long x){
x<0?x=-x,putchar_unlocked('-'):0;static short st[50],top(0);
do st[++top]=x%10,x/=10;while(x);
while(top)putchar_unlocked(st[top--]|48);
}
int l,r;string s;
signed main(){
l=read(),r=read();
cin>>s;
for(re int i=l-1,j=r-1;i<j;++i,--j){
swap(s[i],s[j]);
}
cout<<s;
return 0;
}
T2模拟。NoonMaple 只会出模拟。
口胡一下,由于是字符串,很明显字典树/AC 自动机,蓝。
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define mid (ql+qr>>1)
#define enter putchar_unlocked('\n')
il int read(){
re int x=0,f=1,ch=getchar_unlocked();
for(;!isdigit(ch);ch=getchar_unlocked())if(ch=='-')f=-1;
for(;isdigit(ch);ch=getchar_unlocked())x=(x<<3)+(x<<1)+(ch^48);
return x*f;
}
il void write(long long x){
x<0?x=-x,putchar_unlocked('-'):0;static short st[50],top(0);
do st[++top]=x%10,x/=10;while(x);
while(top)putchar_unlocked(st[top--]|48);
}
string s,t;
signed main(){
cin>>s>>t;
if(s==t){
cout<<"Yes";
return 0;
}
for(re int i=0;i<=s.length();++i){
for(re int j=i+1;j<=s.length();++j){
swap(s[i],s[j]);
if(s==t){
cout<<"Yes";return 0;
}
swap(s[i],s[j]);
}
}
cout<<"No";
return 0;
}
T3模拟。NoonMaple 只会出模拟。NoonMaple 爆 Markdown 了。
口胡一下,但是这题太难了不知道怎么编,灰。
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define mid (ql+qr>>1)
#define enter putchar_unlocked('\n')
il int read(){
re int x=0,f=1,ch=getchar_unlocked();
for(;!isdigit(ch);ch=getchar_unlocked())if(ch=='-')f=-1;
for(;isdigit(ch);ch=getchar_unlocked())x=(x<<3)+(x<<1)+(ch^48);
return x*f;
}
il void write(long long x){
x<0?x=-x,putchar_unlocked('-'):0;static short st[50],top(0);
do st[++top]=x%10,x/=10;while(x);
while(top)putchar_unlocked(st[top--]|48);
}
int n,m;
string xyl[105];
int rk[105],sco[105];
bool cmp(int i,int j){return sco[i]^sco[j]?sco[i]>sco[j]:i<j;}
signed main(){
n=read()*2,m=read();
for(re int i=1;i<=n;++i){
cin>>xyl[i];rk[i]=i;
}
for(re int i=1;i<=m;++i){
for(re int j=1;j*2<=n;++j){
char a=xyl[rk[j*2-1]][i-1],b=xyl[rk[j*2]][i-1];
if(a=='G'){
if(b=='C')sco[rk[j*2-1]]++;
if(b=='P')sco[rk[j*2]]++;
}
if(a=='C'){
if(b=='G')sco[rk[j*2]]++;
if(b=='P')sco[rk[j*2-1]]++;
}
if(a=='P'){
if(b=='C')sco[rk[j*2]]++;
if(b=='G')sco[rk[j*2-1]]++;
}
}
sort(rk+1,rk+n+1,cmp);
}
for(re int i=1;i<=n;++i)write(rk[i]),enter;
return 0;
}
T4差不多是模拟。NoonMaple 差不多只会出模拟。
口胡一下,此题可以找规律,因为后面的东西都是重复的,一眼矩阵快速幂优化 DP,蓝。
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define mid (ql+qr>>1)
#define enter putchar_unlocked('\n')
#define int long long
il int read(){
re int x=0,f=1,ch=getchar_unlocked();
for(;!isdigit(ch);ch=getchar_unlocked())if(ch=='-')f=-1;
for(;isdigit(ch);ch=getchar_unlocked())x=(x<<3)+(x<<1)+(ch^48);
return x*f;
}
il void write(long long x){
x<0?x=-x,putchar_unlocked('-'):0;static short st[50],top(0);
do st[++top]=x%10,x/=10;while(x);
while(top)putchar_unlocked(st[top--]|48);
}
int n,a[100005];int sum,x;int ans;
signed main(){
n=read();
for(re int i=1;i<=n;++i)sum+=(a[i]=read());x=read();
ans+=n*(x/sum);
x%=sum;
for(re int i=1;i<=n;++i){
x-=a[i];
if(x<0){
write(ans+i);return 0;
}
}
return 0;
}
T5扫描线。差不多吧。Xylophone 只会写某些没有意味的无用知识点,就跟 Xylophone 自己一样无用,看来这辈子也就这样了。哦每次只用改一个点,那就是扫描点。排序,相邻时间线间的数量是不变的,将答案增加这段时间线的长度,然后修改答案。
口胡一下,扫描线,蓝。
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define mid (ql+qr>>1)
#define enter putchar_unlocked('\n')
#define int long long
il int read(){
re int x=0,f=1,ch=getchar_unlocked();
for(;!isdigit(ch);ch=getchar_unlocked())if(ch=='-')f=-1;
for(;isdigit(ch);ch=getchar_unlocked())x=(x<<3)+(x<<1)+(ch^48);
return x*f;
}
il void write(long long x){
x<0?x=-x,putchar_unlocked('-'):0;static short st[50],top(0);
do st[++top]=x%10,x/=10;while(x);
while(top)putchar_unlocked(st[top--]|48);
}
struct xyl{int p,op;}a[400005];
int n,cnt,sum,ans[400005];
bool cmp(xyl x,xyl y){return x.p<y.p;}
signed main(){
n=read();
for(re int i=1;i<=n;++i)a[++cnt]={read(),1},++cnt,a[cnt]={read()+a[cnt-1].p,-1};
sort(a+1,a+cnt+1,cmp);
for(re int i=1;i<=cnt;++i){
sum+=a[i].op;
if(a[i].p^a[i+1].p){
ans[sum]+=a[i+1].p-a[i].p;
}
}
for(re int i=1;i<=n;++i)write(ans[i]),putchar_unlocked(' ');
return 0;
}
T6暴力模拟。暴力 NoonMaple 只会出模拟。
为什么都在二进制拆分,真的不是 AI 吗。也许唯一的 AI 是我。我真唐。DFS 怎么不行了。我的 DFS 跑得很快。先排序。记录上次 DFS 的位置,一直往后确保数字从大到小。给出长度限定。注意到不用全部 DFS, 只需要对一半的长度跑就行了。Xylophone 跑得最慢,是人下人,你们见到 Xylophone 顺便踹一脚。
口胡一下,珂朵莉树,CDQ 分治,后面忘了,紫。
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define mid (ql+qr>>1)
#define enter putchar_unlocked('\n')
il int read(){
re int x=0,f=1,ch=getchar_unlocked();
for(;!isdigit(ch);ch=getchar_unlocked())if(ch=='-')f=-1;
for(;isdigit(ch);ch=getchar_unlocked())x=(x<<3)+(x<<1)+(ch^48);
return x*f;
}
il void write(long long x){
x<0?x=-x,putchar_unlocked('-'):0;static short st[50],top(0);
do st[++top]=x%10,x/=10;while(x);
while(top)putchar_unlocked(st[top--]|48);
}
int a[12],n,cnt,b[12],c[12],ans,ct;
bool vis[12];
void dfs(int d,int cur,int lst){
if(cur==d){
ct=0;
for(re int i=1;i<=cnt;++i){
if(!vis[i])c[++ct]=a[i];
}
// sort(b+1,b+d+1),sort(c+1,c+(cnt-d)+1);
int aa=0,bb=0;
for(re int i=1;i<=d;++i)aa*=10,aa+=b[i];
for(re int i=1;i<=cnt-d;++i)bb*=10,bb+=c[i];
ans=max(ans,aa*bb);
return;
}
for(re int i=lst+1;i<=cnt;++i){
b[cur+1]=a[i];
vis[i]=1;
dfs(d,cur+1,i);
vis[i]=0;
}
}
bool cmp(int x,int y){return x>y;}
signed main(){
n=read();
while(n){
a[++cnt]=n%10;n/=10;
}
sort(a+1,a+cnt+1,cmp);
for(re int i=1;i<cnt;++i){
dfs(i,0,0);
}
write(ans);
return 0;
}
我掉分了。我什么都不是。这比赛除了 AI 还有什么。这比赛除了 AI 还有什么。这比赛除了 AI 还有什么。为什么你们都能几十分钟 AK 挑战赛了,ACGO 不应该全是 J1 以上的人吗。为什么 J1 这么少。这比赛除了 AI 还有什么。我居然掉分了。实力的原因,没有 20 分钟 6 提交 AK 我很抱歉,作为人类给你们 AI 拖后腿了。
这里空空如也

















有帮助,赞一个