当前位置: 首页 > news >正文

【LGR-290-Div.4】 ARC224 CF2246

2026/7/12 打了三场比赛。

第一次 Rated 打 ARC。

上一次打 ARC 是受到 zt17 邀请,Unrated 打 ARC223。为了 Rated 打 ARC 在 7/11 打了 ABC466。

洛谷入门赛 #49

19:00~21:00

没什么好说的。打完了才发现等级分限制 \(1200\),我 \(1387\),不能涨等级分。

很快写完了,太简单了不放了。

AtCoder ARC224

20:00~22:00

A

猜测答案为 \(\mathcal O(1)\times k\),所以直接打了个暴力,过了。

容易发现 \(100k\) 是有 \(2\) 个连续零的,所以暴力增加的次数 \(\leq100\)\(T\leq10^5\),可以通过。

赛时代码
//#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<stack>
#include<list>
using namespace std;
typedef long long ll; 
int k;
bool check(ll ans){bool zero=false;do{if(ans%10==0){if(zero){return true;}zero=true;}else{zero=false;}ans/=10;}while(ans);return false;
}
int main(){/*freopen("test.in","r",stdin);freopen("test.out","w",stdout);*/ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int T;cin>>T;while(T--){cin>>k;ll ans=k;for(;!check(ans);ans+=k);cout<<ans<<'\n';}cout.flush();/*fclose(stdin);fclose(stdout);*/return 0;
}

B

手玩一下,发现最优构造就是把它尽量拼成一个正方形,多出来的就在右边和下面。因为你增加一个正方形,只会增加 \(1\sim 2\) 条共边。增加 \(3,4\) 条共边的可调整顺序变成每次 $$

\(x=\left\lfloor\sqrt n\right\rfloor,r=n-x^2\),则有答案为:

\[\begin{cases} 2x(x-1)&r=0\\ 2x(x-1)+2r-1&0<r\leq x\\ 2x(x-1)+2r-2&x<r \end{cases} \]

赛时代码
//#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<stack>
#include<list>
using namespace std;
typedef long long ll;
ll n;
ll f(ll n){ll x=sqrt((long double)n);ll ans=2*x*(x-1);ll r=n-x*x;if(r==0){return ans;}else if(r<=x){ans+=r*2-1;}else{ans+=r*2-2;}return ans;
}
int main(){/*freopen("test.in","r",stdin);freopen("test.out","w",stdout);*/ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int T;cin>>T;while(T--){cin>>n;cout<<f(n)<<'\n';}cout.flush();/*fclose(stdin);fclose(stdout);*/return 0;
}

C

考虑如果是棵树,显然构造 \(a_x=a_{\operatorname{father}(x)}+1\) 即可。但是这是张图。

考虑类似于 Tarjan 的 DFS 树,再构造 \(a_x=a_{\operatorname{father}(x)}+1\) 即可。DFS 过程中如果 \(a_x\) 有值就返回。

赛时代码
//#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<stack>
#include<list>
using namespace std;
constexpr const int N=3e5,M=3e5;
int n,a[N+1];
vector<int>g[N+1];
void dfs(int x,int fx){if(a[x]||x==1){return;}a[x]=a[fx]+1;for(int v:g[x]){dfs(v,x);}
}
int main(){/*freopen("test.in","r",stdin);freopen("test.out","w",stdout);*/ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int T;cin>>T;while(T--){int m;cin>>n>>m;for(int i=1;i<=n;i++){g[i].resize(0);a[i]=0;}while(m--){int u,v;cin>>u>>v;g[u].push_back(v);g[v].push_back(u);}for(int v:g[1]){dfs(v,1);}for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<'\n';}cout.flush();/*fclose(stdin);fclose(stdout);*/return 0;
}

D

赛时代码
//#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<stack>
#include<list>
using namespace std;
typedef long long ll;
constexpr const int N=1e6,K=1e6,V=7;
int n,k,cnt[V+1];
int cost(int n){int ans=0;do{ans++;n/=10;}while(n);return ans;
}
int main(){/*freopen("test.in","r",stdin);freopen("test.out","w",stdout);*/ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int T;cin>>T;while(T--){cin>>n>>k;if(n<=20&&k>(1<<n)){cout<<"-1\n";continue;}memset(cnt,0,sizeof(cnt));for(int i=1;i<=k;i++){cnt[cost(i)]++;}ll ans=0,last=k,p=0,f=1,C=1;for(int d=7;1<=d;d--){while(cnt[d]>0){if(!f){p++;C=C*(n-p+1)/p;C=min(C,last+1);f=min(C,last);}ll pl=min(1ll*cnt[d],f);ans+=pl*p*d;cnt[d]-=pl;f-=pl;last-=pl;}}cout<<ans<<'\n';}cout.flush();/*fclose(stdin);fclose(stdout);*/return 0;
}
/*
1
3 55
*/

E

赛时一直在写 D。然后还有 9min 的时候 zt17 问我怎么不写 E。

我写完 D 后还剩 7min,询问 zt17 7min 能不能写完 E。

他说他 4min 就写完了 /bx/bx。

然而我因为 switch 没写 break 被创飞了。赛后发现,被人机验证一直卡,最后加 break 就过了。

非常简单的发现不能删除的字符会把字符串分割成一个个部分。之后每次字符就贪心和前面匹配,不能匹配就清空前面的并记录答案。

栈模拟即可。

赛时代码
//#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<ctime>
#include<deque>
#include<queue>
#include<stack>
#include<list>
using namespace std;
int main(){/*freopen("test.in","r",stdin);freopen("test.out","w",stdout);*/ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int T;cin>>T;while(T--){string s;cin>>s;vector<char>v;int ans=0;for(char ch:s){switch(ch){case 'A':v.push_back('A');break;case 'B':while(v.size()&&v.back()=='D'){v.pop_back();}if(v.size()&&v.back()=='A'){v.pop_back();v.push_back('D');}else{v.resize(0);ans++;}break;case 'C':while(v.size()&&v.back()=='A') {v.pop_back();}if(v.size()&&v.back()=='D'){v.pop_back();}else{v.resize(0);ans++;}break;}}cout<<ans<<'\n';}cout.flush();/*fclose(stdin);fclose(stdout);*/return 0;
}

Codeforces Round 1108(Div.2)

C

没看懂「non-decreasing」和 DeepSeek、CodeForces Better 翻译的「非递减」就是「单调不降」的意思,虚空思考 20min。

http://www.jsqmd.com/news/1180465/

相关文章:

  • 邯郸黄金回收实测:六家门店报价透明无套路 - 余生黄金回收
  • 架构师如何做技术分享:让知识流动起来
  • 如何快速掌握RVC变声器:AI语音克隆完全指南
  • 深入解析MySQL连接中断:从“Expected to read 4 bytes, read 0 bytes”错误到连接池优化
  • 《Dockerfile语法精讲》-- 从指令到实战,构建高效容器镜像
  • 步进电机3大核心参数选型指南:以28BYJ-48与57HS为例对比静转矩与步距角
  • 【Linux】lsof命令实战:从网络连接到文件恢复的深度排查指南
  • 遗传算法工程化:从早熟收敛到可控演化的实战指南
  • 架构师面试指南:如何回答架构设计问题
  • 副业开店指南!抖店店群完整上货流程:选品采集、合规检测、一键发布分步教学 - 抖掌柜
  • 2026 汉中靠谱装修公司排行榜实测解析,本地正规装企推荐(实地走访 + 工地核验 + 业主回访) - 装修新知
  • VS Code Java Extension Pack 1.0:3步配置外部JAR依赖,打包可执行JAR实战
  • 多模型推理 Pipeline 的性能优化——批处理、模型并行与响应缓存
  • PyTorch张量核心:从维度操作到内存布局的深度解析
  • wayca-scheduler-bench与容器化环境:如何在Kubernetes中运行性能测试?
  • Oh-My-Zsh 插件生态深度解析:5个必装插件提升终端效率200%
  • 2026 苏州飘窗漏水反复修不好该怎么彻底解决?5 家机构技术能力实测 - 徽顺虹
  • 2026苏州婚纱摄影排名TOP5:口碑实力全维度测评,备婚优选指南 - 江湖评测
  • UnityWebRequest内存泄露终结方案:从根因到实战优化
  • SPSS 数据拆分与子集选取:2种方法应对5类群体分析场景
  • HarmonyOS7 Swiper 轮播:banner 自动播放案例
  • 从MySQL到DM8:TP5项目国产化迁移中的数据库适配与核心代码改造实战
  • 2026 沈阳靠谱黄金回收商家推荐,无损耗无折旧费 - 奢品小当家
  • 腾讯云短信 API 错误 1012/1016 排查指南:签名模板审核与 3 种配置问题定位
  • 终极指南:如何免费使用Poppins多语言几何字体提升设计品质
  • STM32F334R8与MCP3551高精度ADC接口设计与优化
  • 百达翡丽保养一次多少钱官方售后费用标准解析权威公示(2026年7月最新) - 百达翡丽官方售后中心
  • PIC18F87J10与DTH-08传感器上拉电阻配置与通信实现
  • BarrageGrab技术深度解析:高性能实时直播弹幕抓取架构设计指南
  • 亨得利官方名表服务中心|最新热线和完整地址权威信息声明(2026年7月最新) - 亨得利官方博客