Dytechlab Cup 2022 (A - C)

A - Ela Sorting Books

分析:贪心,将字符串每一位都存在map里,从前往后尽量让每一个\(n / k\)的段\(mex\)值尽量大,模拟mex即可。

void solve(){
int n,k;
cin >> n >> k;
string s;
cin >> s;
map<char,int> mp;
int d = n / k;
set<char> st;
for (int i =0;i < n;i++) {
mp[s[i]]++;
}
while(k--){
bool f = false;
for (int j = 0; j < d;j ++) {
if(mp['a' + j] > 0) {
mp['a' + j]--;
}
else {
f = true;
cout << char ('a' + j);
break;
}
}
if(!f) cout << char('a' + d);
}
cout << endl;
}

B - Ela's Fitness and the Luxury Number

分析:我自己也不太会证qwq,大概思路就是,因为这题数据量很大,可以肯定是\(O(1)\)计算无疑了,打表猜公式即可。

int rcl(int x) {
int d = sqrt(x);
int res = (int)(sqrt(x) - 1);
res *= 3;
int now = d * d;
while(now <= x){
now += d;
res++;
}
return res;
}
void solve(){
int l,r;
cin >> l >> r;
int ans1 = rcl(r);
int ans2 = rcl(l);
int q = 0;
if(l % (int)(sqrt(l)) == 0)q++;
cout << ans1 - ans2 + q<< endl; }

C - Ela and Crickets

分析:画图模拟,很容易可以看出,以开始的点画十字,是可以跳到的位子,如何判断是否在十字内呢,只要目标点和出发的中心 \(x\)或\(y\)满足有一个绝对差是偶数倍即可。

还需要考虑边界情况,如果出发的中心在棋盘的四个角,那只能是一条横着的直线和竖着的直线了。

void solve(){
int n;
cin >> n;
PII cp[5];
for (int i = 1;i <= 3;i++) {
cin >> cp[i].first >> cp[i].second;
}
int ax,ay;
cin >> ax >> ay;
sort(cp+1,cp+3);
map<int,int> mp1;
map<int,int> mp2;
int tagx;
int tagy;
for (int i = 1;i <= 3;i ++) {
mp1[cp[i].first]++;
mp2[cp[i].second]++;
if(mp1[cp[i].first] == 2) tagx = cp[i].first;
if(mp2[cp[i].second] == 2) tagy = cp[i].second;
}
if((tagx == 1 && tagy == 1) || (tagx == n && tagy == 1) || (tagx == 1 && tagy == n) || (tagx == n && tagy == n)) {
if(tagx == ax || tagy == ay) {
cout << "YES" << endl;
return ;
}
else {
cout << "NO" << endl;
return ;
}
}
else {
if(abs(ax - tagx) % 2 == 0 || abs(tagy - ay) % 2 == 0 ) {
cout <<"YES" << endl;
return ;
}
else {
cout <<"NO" << endl;
return ;
}
} }

Dytechlab Cup 2022 (A - C)的更多相关文章

  1. [题解] Codeforces Dytechlab Cup 2022 1737 A B C D E 题解

    傻*Dytechlab还我rating!(不过目前rating还没加上去,据说E是偷的说不定要unrated) 实在没预料到会打成这样... 求点赞 点我看题 A. Ela Sorting Books ...

  2. java高cup占用解决方案

    项目中发现java cpu占用高达百分之四百,查看代码发现有一个线程在空转,拉高了cup while(true){ } 解决方案,循环中加入延迟:Thread.sleep(Time): 总结下排查CP ...

  3. UVALive 7147 World Cup(数学+贪心)(2014 Asia Shanghai Regional Contest)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...

  4. uva 6757 Cup of Cowards(中途相遇法,貌似)

    uva 6757 Cup of CowardsCup of Cowards (CoC) is a role playing game that has 5 different characters (M ...

  5. 【转】关于KDD Cup '99 数据集的警告,希望从事相关工作的伙伴注意

    Features From: Terry Brugger Date: 15 Sep 2007 Subject: KDD Cup '99 dataset (Network Intrusion) cons ...

  6. Facebook Hacker Cup 2014 Qualification Round 竞赛试题 Square Detector 解题报告

    Facebook Hacker Cup 2014 Qualification Round比赛Square Detector题的解题报告.单击这里打开题目链接(国内访问需要那个,你懂的). 原题如下: ...

  7. DP VK Cup 2012 Qualification Round D. Palindrome pairs

    题目地址:http://blog.csdn.net/shiyuankongbu/article/details/10004443 /* 题意:在i前面找回文子串,在i后面找回文子串相互配对,问有几对 ...

  8. [BZOJ 3145][Feyat cup 1.5]Str 解题报告

    [Feyat cup 1.5]Str DescriptionArcueid,白姬,真祖的公主.在和推倒贵看电影时突然对一个问题产生了兴趣:我们都知道真祖和死徒是有类似的地方.那么从现代科学的角度如何解 ...

  9. HDU 2289 CUP 二分

    Cup Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

随机推荐

  1. 技术分享 | innodb_buffer_pool_size为什么无法调低至1GB以内

    前言 innodb_buffer_pool_size可以调大,却不能调小至1GB以内,这是为什么? MySQL 版本:5.7.30 测试环境有台 MySQL 服务器反应很慢,检查系统后发现内存使用量已 ...

  2. 解决国内不能访问github的问题

    问题 最近访问GitHub总是不稳定,经常连不上, 出各种错误(OpenSSL SSL_read: Connection was reset, errno 10054, Connection refu ...

  3. Go语言 context包源码学习

    你必须非常努力,才能看起来毫不费力! 微信搜索公众号[ 漫漫Coding路 ],一起From Zero To Hero ! 前言 日常 Go 开发中,Context 包是用的最多的一个了,几乎所有函数 ...

  4. Java八股文纯享版——篇①:Java基础

    注: 1.笔记为个人归纳整理,尽力保证准确性,如有错误,恳请指正 2.写文不易,转载请注明出处 3.本文首发地址 https://blog.leapmie.com/archives/b8fe0da9/ ...

  5. 使用Python的selenium库制作脚本,支持后台运行

    本文介绍如何使用Python的selenium库制作脚本.概念:       Selenium是一个用于测试网站的自动化测试工具,支持各种浏览器包括Chrome.Firefox.Safari等主流界面 ...

  6. 【Azure 应用服务】在 App Service for Windows 中自定义 PHP 版本的方法

    问题描述 在App Service for Windows的环境中,当前只提供了PHP 7.4 版本的选择情况下,如何实现自定义PHP Runtime的版本呢? 如 PHP Version 8.1.9 ...

  7. Html飞机大战(五):主角登场(英雄类编辑)

    好家伙, 遇到了一些非常奇怪的bug index.html:179 Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRender ...

  8. API设计中性能提升的10种解决方法

    api的设计涉及到的方面很多, 分类是一个基本的思考方式.如果可以形成一个系列性的文字,那就从性能开始吧. 就像任何性能一样,API 性能主要取决于如何响应不同类型的请求.例如:典型的电商场景,显示用 ...

  9. KingbaseES V8R6集群维护案例之---停用集群node_export进程

    案例说明: 在KingbaseES V8R6集群启动时,会启动node_exporter进程,此进程主要用于向kmonitor监控服务输出节点状态信息.在系统安全漏洞扫描中,提示出现以下安全漏洞: 对 ...

  10. KingbaseES V8R6集群部署案例之---Windows环境配置主备流复制(异机复制)

    案例说明: 目前KingbaseES V8R6的Windows版本不支持数据库sys_rman的物理备份,可以考虑通过建立主备流复制实现数据库的异机物理备份.本案例详细介绍了,在Windows环境下建 ...