Toyota Programming Contest 2024#12(AtCoder Beginner Contest 384)题解

news/2025/2/28 15:47:49/文章来源:https://www.cnblogs.com/gutongxing/p/18607252

总体情况

image

image

感觉这次在起飞。

20 分钟后就在罚坐。

A - aaaadaa

题目描述

给定一个长度为 \(N\) 的字符串 \(S\) ,由小写英文字母以及小写英文字母 \(c_1\)\(c_2\) 组成。

查找将 \(S\) 中所有不属于 \(c_1\) 的字符替换为 \(c_2\) 后得到的字符串。

思路分析

直接模拟。

代码

// Problem: A - aaaadaa
// Contest: AtCoder - Toyota Programming Contest 2024#12(AtCoder Beginner Contest 384)
// URL: https://atcoder.jp/contests/abc384/tasks/abc384_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
//#define int long long
namespace gtx{
//	Fast IOvoid read(int &x){x = 0;int h = 1;char tmp;do{tmp=getchar();if(tmp=='-')h*=-1;}while(!isdigit(tmp));while(isdigit(tmp)) x*=10,x+=tmp-'0',tmp=getchar();x*=h;}void read(char &x){do{x=getchar();}while(x==' '||x=='\n'||x=='\r');}void write(char x){putchar(x);}void write(int x){if(x<0) putchar('-'),x=-x;int st[200]={0},tot=0;do{st[++tot]=x%10,x/=10;} while(x);while(tot){putchar(st[tot--]+'0');}}void write(int x,char y){write(x);write(y);}#ifndef intvoid read(long long &x){x = 0;int h = 1;char tmp;do{tmp=getchar();if(tmp=='-')h*=-1;}while(!isdigit(tmp));while(isdigit(tmp)) x*=10,x+=tmp-'0',tmp=getchar();x*=h;}void write(long long x){if(x<0) putchar('-'),x=-x;int st[200]={0},tot=0;do{st[++tot]=x%10,x/=10;} while(x);while(tot){putchar(st[tot--]+'0');}}void write(long long x,char y){write(x);write(y);}#endifsigned main(){int n;char a,b;string s;cin >> n >> a >> b >> s;for(char i:s){if(i==a) cout << a;else cout <<b;}return 0;}
}
signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
//	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int T = 1;
//	gtx::read(T);while(T--) gtx::main();return 0;
}

B - ARC Division

题目描述

AtCoder 常规竞赛 (ARC) 分为两个部分。

  • 在 ARC Div. \(1\) 中,竞赛开始时评分在 \(1600\)\(2799\) 之间(含)的参与者需要更新评分。
  • 在 ARC Div. \(2\) 中,竞赛开始时评分在 \(1200\)\(2399\) 之间(含)的参与者需要更新评分。

Takahashi 决定参加 \(N\) ARC。

最初,他的评分为 \(R\)

\(i\)\((1\leq i\leq N)\) ARC 是 Div. \(D _ i\) ,他在该比赛中的表现用整数 \(A _ i\) 表示。

如果他在第 \(i\) -th ARC 中需要更新评级,则让 \(T\) 成为他在该比赛开始时的评级。然后,比赛结束后,他的评级变为 \(T+A _ i\)

如果他不需要更新评级,则他的评级不会改变。

ARC 的评级更新在比赛结束后立即进行,他是否需要在下一场比赛中进行评级更新取决于更新后的评级。

完成 \(N\) ARC 后查找他的评级。

除了这些 \(N\) ARC 之外,他不参加任何比赛,他的评级不会以其他方式发生变化。

思路分析

直接模拟即可。

代码

// Problem: B - ARC Division
// Contest: AtCoder - Toyota Programming Contest 2024#12(AtCoder Beginner Contest 384)
// URL: https://atcoder.jp/contests/abc384/tasks/abc384_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
namespace gtx{
//	Fast IOvoid read(int &x){x = 0;int h = 1;char tmp;do{tmp=getchar();if(tmp=='-')h*=-1;}while(!isdigit(tmp));while(isdigit(tmp)) x*=10,x+=tmp-'0',tmp=getchar();x*=h;}void read(char &x){do{x=getchar();}while(x==' '||x=='\n'||x=='\r');}void write(char x){putchar(x);}void write(int x){if(x<0) putchar('-'),x=-x;int st[200]={0},tot=0;do{st[++tot]=x%10,x/=10;} while(x);while(tot){putchar(st[tot--]+'0');}}void write(int x,char y){write(x);write(y);}#ifndef intvoid read(long long &x){x = 0;int h = 1;char tmp;do{tmp=getchar();if(tmp=='-')h*=-1;}while(!isdigit(tmp));while(isdigit(tmp)) x*=10,x+=tmp-'0',tmp=getchar();x*=h;}void write(long long x){if(x<0) putchar('-'),x=-x;int st[200]={0},tot=0;do{st[++tot]=x%10,x/=10;} while(x);while(tot){putchar(st[tot--]+'0');}}void write(long long x,char y){write(x);write(y);}#endifsigned main(){int n,r;cin >>n >> r;for(int i = 1;i<=n;i++){int d,a;cin >> d >>a;if(d==1){if(1600<=r&&r<=2799) r+=a;}else if(d==2){if(1200<=r&&r<=2399) r+=a;}}cout << r;return 0;}
}
signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
//	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int T = 1;
//	gtx::read(T);while(T--) gtx::main();return 0;
}

C - Perfect Standings

题目描述

Takahashi 决定举办一次编程竞赛。

竞赛包含五道题目:A、B、C、D、E,得分分别为 \(a\)\(b\)\(c\)\(d\)\(e\)

共有 \(31\) 名参赛者,他们都至少解决了一道题目。

更具体地说,对于字符串 ABCDE 的每个非空子序列(不一定连续),都有一个以该子序列命名的参赛者,他解决了与其名字中字母对应的题目,而没有解决其他题目。

例如,参赛者 A 只解决了题目 A,参赛者 BCE 解决了题目 B、C 和 E。

按得分从大到小的顺序打印参赛者的姓名。参与者获得的分数是他们所解决问题的分数的总和。

如果两个参与者获得的分数相同,则首先打印名字在字典中较小的参与者。

“字典中较小”是什么意思?

简而言之,“字典中较小”是指单词在字典中出现的顺序。

更准确地说,对于由大写英文字母组成的不同字符串 \(S,T\) ,如果满足以下任一条件,则 \(S\) 在字典中小于 \(T\)

  • \(S\) 的长度 \(|S|\) 小于 \(T\) 的长度,并且 \(T\) 的前 \(|S|\) 个字符与 \(S\) 匹配。
  • 存在一个整数 \(1\leq i\leq\min\{ |S|,|T|\}\) ,它同时满足以下两个条件:
  • 对于每个整数 \(j\) ,其值为 \(1\leq j\lt i\)\(S\) 的第 \(j\) 个字符等于 \(T\) 的第 \(j\) 个字符。
  • \(S\) 的第 \(i\) 个字符按字母顺序小于 \(T\) 的第 \(i\) 个字符。

例如,如果 \(S=\) AB\(T=\) ABC,则第一个条件成立,因此 \(S\) 按字典顺序小于 \(T\) 。如果 \(S=\) ABD\(T=\) ACD,则第二个条件对 \(i=2\) 成立,因此 \(S\) 按字典顺序小于 \(T\)

思路分析

暴力搜索,然后放入一个 pair<int,string> 排序就行。

代码

// Problem: C - Perfect Standings
// Contest: AtCoder - Toyota Programming Contest 2024#12(AtCoder Beginner Contest 384)
// URL: https://atcoder.jp/contests/abc384/tasks/abc384_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
namespace gtx{
//	Fast IOvoid read(int &x){x = 0;int h = 1;char tmp;do{tmp=getchar();if(tmp=='-')h*=-1;}while(!isdigit(tmp));while(isdigit(tmp)) x*=10,x+=tmp-'0',tmp=getchar();x*=h;}void read(char &x){do{x=getchar();}while(x==' '||x=='\n'||x=='\r');}void write(char x){putchar(x);}void write(int x){if(x<0) putchar('-'),x=-x;int st[200]={0},tot=0;do{st[++tot]=x%10,x/=10;} while(x);while(tot){putchar(st[tot--]+'0');}}void write(int x,char y){write(x);write(y);}#ifndef intvoid read(long long &x){x = 0;int h = 1;char tmp;do{tmp=getchar();if(tmp=='-')h*=-1;}while(!isdigit(tmp));while(isdigit(tmp)) x*=10,x+=tmp-'0',tmp=getchar();x*=h;}void write(long long x){if(x<0) putchar('-'),x=-x;int st[200]={0},tot=0;do{st[++tot]=x%10,x/=10;} while(x);while(tot){putchar(st[tot--]+'0');}}void write(long long x,char y){write(x);write(y);}#endifvector<pair<int,string>> v;string now;int a[6];void dfs(char tmp,int s){if(tmp=='F'){if(now=="") return;v.push_back({-s,now});return;}dfs(tmp+1,s);now+=tmp;s+=a[tmp-'A'];dfs(tmp+1,s);now.erase(--now.end());s-=a[tmp-'A'];}signed main(){cin >>a[0] >>a[1 ] >> a[2] >> a[3] >> a[4];dfs('A',0);sort(v.begin(),v.end());for(auto i:v) cout << i.second <<endl;return 0;}
}
signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
//	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int T = 1;
//	gtx::read(T);while(T--) gtx::main();return 0;
}

D - Repeated Sequence

题目描述

给定一个无限序列 \(A=(A _ 1,A _ 2,A _ 3,\dotsc)\) ,其周期为 \(N\) ,前 \(N\)\(A _ 1,A _ 2,\dotsc,A _ N\)

确定此无限序列是否存在一个非空的连续子序列,其和为 \(S\)

这里,当对每个整数 \(i > N\) 都有 \(A _ i=A _ {i-N}\) 时,无限序列 \(A\) 的周期为 \(N\)

思路分析

首先对总和取模。

否则直接枚举区间,发现具有单调性,直接双指针。

代码

// Problem: D - Repeated Sequence
// Contest: AtCoder - Toyota Programming Contest 2024#12(AtCoder Beginner Contest 384)
// URL: https://atcoder.jp/contests/abc384/tasks/abc384_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
namespace gtx{
//	Fast IOvoid read(int &x){x = 0;int h = 1;char tmp;do{tmp=getchar();if(tmp=='-')h*=-1;}while(!isdigit(tmp));while(isdigit(tmp)) x*=10,x+=tmp-'0',tmp=getchar();x*=h;}void read(char &x){do{x=getchar();}while(x==' '||x=='\n'||x=='\r');}void write(char x){putchar(x);}void write(int x){if(x<0) putchar('-'),x=-x;int st[200]={0},tot=0;do{st[++tot]=x%10,x/=10;} while(x);while(tot){putchar(st[tot--]+'0');}}void write(int x,char y){write(x);write(y);}#ifndef intvoid read(long long &x){x = 0;int h = 1;char tmp;do{tmp=getchar();if(tmp=='-')h*=-1;}while(!isdigit(tmp));while(isdigit(tmp)) x*=10,x+=tmp-'0',tmp=getchar();x*=h;}void write(long long x){if(x<0) putchar('-'),x=-x;int st[200]={0},tot=0;do{st[++tot]=x%10,x/=10;} while(x);while(tot){putchar(st[tot--]+'0');}}void write(long long x,char y){write(x);write(y);}#endifconst int MAXN = 4e5+10;int n,s,a[MAXN],p,sum[MAXN];signed main(){read(n);read(s);for(int i = 1;i<=n;i++) read(a[i]),p+=a[i],sum[i] = sum[i-1]+a[i];for(int i = n+1;i<=2*n;i++) a[i] = a[i-n],sum[i] = sum[i-1]+a[i];s%=p;if(s==0) return puts("Yes");int l = 1,r = 1;while(l<=2*n){while(sum[r]-sum[l-1]<s&&r<=2*n) r++;if(sum[r]-sum[l-1]==s) return puts("Yes");l++;}puts("No");return 0;}
}
signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
//	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int T = 1;
//	gtx::read(T);while(T--) gtx::main();return 0;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/852675.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

解决2024.1以后新版本IDEA Lombok (@Data)等不生效的问题

做项目做着做着新模块用不了 lombok 真的要崩溃了,各种检查插件、配置,发现都无法恢复;乱试指定版本:终于可用了。。真的有崩溃感

DNS之公共DNS

阿里 AliDNS 阿里公共DNS是阿里巴巴集团推出的DNS递归解析系统,目标是成为国内互联网基础设施的组成部分,面向互联网用户提供“快速”、“稳定”、“智能”的免费DNS递归解析服务。 DNS 服务器 IP 地址: 首选:223.5.5.5 备选:223.6.6.6 阿里公共DNS114DNS 国内用户量巨大的…

NestJS 部署Apache

要将Nest.JS应用搭建在Apache服务器上,你需要了解Nest.JS是一个基于Node.js的框架,因此它本质上是一个后端服务,而Apache通常用作前端服务器或反向代理。以下是将Nest.JS应用与Apache服务器结合使用的步骤: 一、准备环境安装Node.js:确保在服务器上安装了Node.js。你可以从…

综合设计——多源异构数据采集与融合应用综合实践

这个项目属于哪个课程2024数据采集与融合技术实践 组名 从你的全世界爬过团队logo:项目简介 项目名称:博物识植项目logo:项目介绍:在探索自然奥秘的旅途中,我们常与动植物相伴而行,却无法准确识别它们,更难以深入了解他们的特征。为了更好地理解和欣赏自然界的多样性,…

maven docker-maven-plugin 发布docker 20241214

1、docker开启远程访问 端口 2375docker主机:192.168.177.128 vi /usr/lib/systemd/system/docker.service #修改ExecStart这行 ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 #重新加载配置文件 [root@localhost ~]# systemctl daemon-reload #重启服务 [root@lo…

10大关键技术解构:智能合同审查系统全景解析

前言 随着企业数字化转型的深入,合同管理在业务流程中的重要性愈加凸显。传统的人工审查合同方式不仅耗时耗力,还容易出现疏漏,尤其在复杂法律条款和跨部门协作的场景中,这一问题尤为明显。为了解决这一痛点,思通数科智能合同审查系统应运而生。基于人工智能和大数据分析的…

2024-2025-1 20241403《计算机基础与程序设计》第十二周学习总结

2024-2025-1 20241403《计算机基础与程序设计》第十二周学习总结 作业信息这个作业属于哪个课程 <班级的链接>(如2024-2025-1-计算机基础与程序设计)这个作业要求在哪里 <作业要求的链接>(如2024-2025-1计算机基础与程序设计第一周作业)这个作业的目标 指针与一维…

我的新博客 MarisaMagics Blog

新博客地址 MarisaMagics Blog 最近用 github + hexo 配置了一个新的博客,以后可能基本上都在新博客平台上更新文章 DA⭐ZE ~一切都是命运石之门的选择,本文章来源于博客园,作者:MarisaMagic,出处:https://www.cnblogs.com/MarisaMagic/p/18607182,未经允许严禁转载

locust 压力测试工具windows平台从零开始安装使用

locust是一个用python写的接口压力测试应用,我们只需要编写简单的代码才能运行测试,前期安装需要一点python基础。 用以测试的接口需要一个一个通过代码添加,如下: 这就是一个测试的接口了,很简单,只需要接口的路径和参数,接口的主机地址会在web端输入: locust需要pyth…

OpenDaylight下发流表

实验一:单流表(v1.0) 下发流表实现h1和h2之间不能互通。 1、启动OpenDaylight ./karaf查看6633端口是否处于监听状态 netstat -an | grep 6633在物理机浏览器中访问虚拟机ip:8181/index.html登录OpenDaylight网页端。 账号密码都是admin。后面做实验的时候,出现过无法登录的…