Codeforces Round #606 Div. 2 比赛总结
比赛情况
bq. A题 Wrong Answer on test 2 , E题sb题没切。bqbqbq.
比赛总结
bq.
那就直接上题解吧!-
A
数位dp,分类讨论,注意细节。
Talk is cheap.Show me the code.
#include<bits/stdc++.h>
using namespace std;
inline int read() {
int x=0,f=1; char ch=getchar();
while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
return x * f;
}
int n,m,ans,L;
void work() {
n = read(), ans = 0;
L = 0, m = n;
while(m/10) ++L, m /= 10;
ans += L * 9;
L = 1, m = n;
while(m/10) L = (L*10)+1, m /= 10;
ans += n/L;
printf("%d\n",ans);
}
int main()
{
int T = read();
while(T--) work();
return 0;
}
B
我们把数值一样的数放在一起,扔进堆里。按数值从大到小处理就OK了。
注意值域比较大,用一下 \(STL\) 里面的 map。
Talk is cheap.Show me the code.
#include<bits/stdc++.h>
using namespace std;
inline int read() {
int x=0,f=1; char ch=getchar();
while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
return x * f;
}
const int N = 2e5+7;
int n;
int a[N];
void work() {
map<int,int> s;
priority_queue<int> q;
n = read(); int ans = 0;
for(int i=1;i<=n;++i) {
a[i] = read();
if(s[a[i]]==0) {
q.push(a[i]);
}
++s[a[i]];
}
while(!q.empty()) {
int now = q.top(); q.pop();
if(now&1) continue;
if(s[now/2]==0) q.push(now/2);
s[now/2] += s[now]; ans++;
//printf("ans += s[%d], s[now]=%d\n",now,s[now]);
}
printf("%d\n",ans);
}
int main()
{
//freopen("a.out","w",stdout);
int T = read();
while(T--) work();
return 0;
}
C
贪心题。
如果有 twone 则删去 'o',否则删去中间这个,比如 one 删去 'n'。这样是对的。
然后模拟即可。
Talk is cheap.Show me the code.
#include<bits/stdc++.h>
using namespace std;
inline int read() {
int x=0,f=1; char ch=getchar();
while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
return x * f;
}
void work() {
string s; cin>>s; vector<int> Ans;
for(int i=1;i<s.length();++i) {
char a = s[i-1], b = s[i], c = s[i+1];
if(a=='t' && b=='w' && c=='o') {
if(s[i+2]=='n' && s[i+3]=='e') s[i+1] = '-', Ans.push_back(i+1)/*, i = i+3+1*/;
else s[i] = '-', Ans.push_back(i)/*, i = i+1+1*/;
} else if(a=='o' && b=='n' && c=='e') {
Ans.push_back(i);
}
}
printf("%d\n",(int)Ans.size());
for(int i=0;i<Ans.size();++i) printf("%d ",Ans[i]+1);
puts("");
}
int main()
{
//freopen("a.out","w",stdout);
int T = read();
while(T--) work();
return 0;
}
D
待补坑。
E
炒鸡简单
考虑一张下面这样的图:

答案不就是两个蓝色部分的大小相乘吗?(题目不考虑A,B两点)
这不就是Dfs的事吗qwq
(其实如果这两块蓝色的有边将他们连起来了就是 puts("0"))
Talk is cheap.Show me the code.
#include<bits/stdc++.h>
using namespace std;
inline int read() {
int x=0,f=1; char ch=getchar();
while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
while(ch>='0'&&ch<='9') { x=(x<<3)+(x<<1)+(ch^48); ch=getchar(); }
return x * f;
}
const int N = 2e5+7, M = 5e5+7;
int n,m,a,b,cnt,flag,tot;
int head[N],vis[N];
struct Edge {
int next,to;
}edge[M<<1];
inline void add(int u,int v) {
edge[++cnt] = (Edge)<%head[u],v%>;
head[u] = cnt;
}
void Dfs(int u,int F) {
flag |= (u==F); vis[u] = 1; ++tot;
for(int i=head[u];i;i=edge[i].next) {
int v = edge[i].to;
if(!vis[v]) Dfs(v,F);
}
}
void work() {
memset(head, 0, sizeof(head)); cnt = flag = 0;
n = read(), m = read(), a = read(), b = read();
for(int i=1,u,v;i<=m;++i) {
u = read(), v = read();
add(u,v), add(v,u);
}
memset(vis, 0, sizeof(vis));
vis[a] = 1; int n1 = 0, n2 = 0, nxt = 0;
for(int i=head[a];i;i=edge[i].next) {
int v = edge[i].to; tot = 0; Dfs(v,b);
if(flag) {
n1 = n - tot - 1; break;
}
}
memset(vis, 0, sizeof(vis));
vis[b] = 1; flag = 0;
for(int i=head[b];i;i=edge[i].next) {
int v = edge[i].to; tot = 0; Dfs(v,a);
if(flag) {
n2 = n - tot - 1; break;
}
}
printf("%lld\n",(long long)(1ll*n1*n2));
}
int main()
{
int T = read();
while(T--) work();
return 0;
}
F
待补坑。
Codeforces Round #606 Div. 2 比赛总结的更多相关文章
- 【cf比赛记录】Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)
比赛传送门 只能说当晚状态不佳吧,有点头疼感冒的症状.也跟脑子没转过来有关系,A题最后一步爆搜没能立即想出来,B题搜索没有用好STL,C题也因为前面两题弄崩了心态,最后,果然掉分了. A:简单数学 B ...
- Codeforces Round #606 (Div. 1) Solution
从这里开始 比赛目录 我菜爆了. Problem A As Simple as One and Two 我会 AC 自动机上 dp. one 和 two 删掉中间的字符,twone 删掉中间的 o. ...
- Codeforces Round #605 (Div. 3) 比赛总结
比赛情况 2h才刀了A,B,C,D.E题的套路做的少,不过ygt大佬给我讲完思路后赛后2min就AC了这题. 比赛总结 比赛时不用担心"时间短,要做多快",这样会匆匆忙忙,反而会做 ...
- 20191214 Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)
概述 切了 ABCE,Room83 第一 还行吧 A - Happy Birthday, Polycarp! 题解 显然这样的数不会很多. 于是可以通过构造法,直接求出 \([1,10^9]\) 内所 ...
- Codeforces Round #606 (Div. 2)
传送门 A. Happy Birthday, Polycarp! 签到. Code /* * Author: heyuhhh * Created Time: 2019/12/14 19:07:57 * ...
- Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)
链接 签到题,求出位数,然后9*(位数-1)+ 从位数相同的全一开始加看能加几次的个数 #include<bits/stdc++.h> using namespace std; int m ...
- Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4) 题解
Happy Birthday, Polycarp! Make Them Odd As Simple as One and Two Let's Play the Words? Two Fairs Bea ...
- Codeforces Round #606 (Div. 2) E - Two Fairs(DFS,反向思维)
- Codeforces Round #606 (Div. 2) D - Let's Play the Words?(贪心+map)
随机推荐
- iOS 图表工具charts之CombinedChartView
关于charts的系列视图介绍传送门: iOS 图表工具charts介绍 iOS 图表工具charts之LineChartView iOS 图表工具charts之BarChartView iOS 图表 ...
- prism 4 模块配置 管理
本章导读: 第四章讲述了模块化应用程序开发中模块的生命周期,生成方法,实例引用的存活时间等关键内容,和经常会应用到的包含定义模块在内的7种场景(以Unity为例,也说明了MEF与Unity中可能不同的 ...
- 阶段3 2.Spring_09.JdbcTemplate的基本使用_2 JdbcTemplate的概述和入门
先看这张图 1.spring中的JdbcTemplate JdbcTemplate的作用: 它就是用于和数据库交互的,实现对表的CRUD操作 如何创建该对象: ...
- SparseLDA算法
2 SparseLDA算法 本章将介绍一种Gibbs Sampling算法的加速算法——SparseLDA [9],它主要利用LDA 模型的稀疏性,来达到加速以及节省内存的目的,是一种精确算法(没有近 ...
- svn导出项目到myeclipse,运行报ClassNotFoundException
一开始以为是 这样的svn导出项目到myeclipse,运行报ClassNotFoundException 后来不行 又看了一下 还不行 以为是这样的MyEclipse2014报错java.lang ...
- python目录和引用关系
这是我的项目目录 像这样引用没有直接画横线 但是运行时会报错:找不到 typeidea.typeidea.文件路径 图片拖出来看更清晰 后期补充: 解决方案: 如:右击:typeidea----- ...
- XSS的简单过滤和绕过
XSS的简单过滤和绕过 程序猿用一些函数将构成xss代码的一些关键字符给过滤了.但是,道高一尺魔高一丈,虽然过滤了,还是可以尝试进行过滤绕过,以达到XSS攻击的目的. 最简单的是输入<scrip ...
- TypeError: reduction operation 'argmax' not allowed for this dtype
这个错误真的tmd伤脑筋.我用idxmax函数去求series类型的最大值的索引,结果明明是下面这种数据, 无论我如何pint他的shape,type,他怎么看都是一个满足idxmax函数要求的参数类 ...
- windows OS安全配置【持续更新20190618】
https://www.52stu.org/?p=76 来源:5号暗区 5号黯区 五号黯区 5号暗区 windows系统的一些加固方法等 关闭445端口: REG ADD HKLM\SYSTEM\Cu ...
- hive udf编程教程
hive udf编程教程 https://blog.csdn.net/u010376788/article/details/50532166