A Commentary Boxes

算出$N \pmod M$

然后分别讨论是加还是减

#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#define int long long
using namespace std;
inline int read() {char c = getchar(); int x = 0, f = 1;while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();return x * f;
}
int N, M, A, B;
main() {N = read(); M = read(); A = read(), B = read();int res = N % M;printf("%lld", min((M - res) * A, res * B));
}

A

B Micro-World

排序之后用一个栈维护当前的病毒

然后不断吞就好了

#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#define int long long
using namespace std;
const int MAXN = 1e6 + 10;
inline int read() {char c = getchar(); int x = 0, f = 1;while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();return x * f;
}
int N, K;
int a[MAXN], s[MAXN], top = 0;
main() {N = read(); K = read();for(int i = 1; i <= N; i++) a[i] = read();sort(a + 1, a + N + 1);int ans = 0;s[++top] = a[1];for(int i = 2; i <= N; i++) {while(top > 0 && (a[i] > s[top]) && (a[i] <= s[top] + K)) ans++, top--;s[++top] = a[i];}printf("%d", N - ans);
}

B

C Bracket Sequences Concatenation Problem

类似于$)($的肯定是不管与谁都无法匹配

$(($这样的只能匹配$))$,反过来同理

$()$这样合法的于合法的都能匹配

然后记录一下乘法原理统计答案

#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#include<cstring>
#define LL long long
using namespace std;
const int MAXN = 3e5 + 10;
int N, M, A, B;
int s[MAXN];
LL top = 0, L[MAXN], R[MAXN], can, limit = 0;
char ss[MAXN];
main() {//freopen("a.in", "r", stdin);//freopen("c.out", "w", stdout);int N;scanf("%d", &N);for(int i = 1; i <= N; i++) {scanf("%s", ss + 1);top = 0;int Len = strlen(ss + 1);bool flag = 0;for(int j = 1; j <= Len; j++)    {if(ss[j] == '(') s[++top] = 1;if(ss[j] == ')') {if(top > 0 && s[top] == 1) top--;else s[++top] = 2;}}for(int j = 2; j <= top; j++)if(s[j] != s[j - 1]){flag = 1; break;}if(flag == 1) continue;limit = max(limit, top);if(top == 0) {L[0]++; R[0]++; continue;}if(s[top] == 2) R[top]++;if(s[top] == 1) L[top]++;}LL ans = 0;for(int i = 0; i <= limit; i++)ans += 1ll * L[i] * R[i];printf("%lld\n", ans);}

C

D Graph And Its Complement

第一次遇到构造题

首先当$a,b$同时不唯一的时候一定是无解的,

证明:假设原图的联通块数不为$1$,那么原图中不同联通块之间的点在反图中一定有边,

这样原图中的不同联通块之间的点可以通过新边到达其他联通块,

然后再通过其他联通块的新边回到原来的联通块

这样我们假设$a=1$(若不满足可以交换)

设$b=x$

首先我们把原图中的边全都连上,然后在原图中任意$N-x$对点的边断开就好

注意要特判$N=2$和$N=3$的情况

#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#define LL long long
using namespace std;
const LL MAXN = 1001, INF = 1e18 + 10;
inline int read() {char c = getchar(); int x = 0, f = 1;while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();return x * f;
}
char ans[MAXN][MAXN];
main() {int N = read(), A = read(), B = read();if(A != 1 && B != 1) { printf("NO"); return 0;}char a = '1', b = '0'; if(A != 1) swap(a, b), swap(A, B);if((N == 2 || N == 3) && B == 1) { printf("NO"); return 0;}printf("YES\n");for(int i = 1; i <= N; i++)for(int j = 1; j <= N; j++)if(i != j) ans[i][j] = a;else ans[i][j] = '0';for(int i = 1; i <= (N - B); i++) ans[i][i + 1] = b, ans[i + 1][i] = b;for(int i = 1; i <= N; i++, puts(""))for(int j = 1; j <= N; j++)putchar(ans[i][j]);
}

D

E Post Lamps

预处理出障碍,

直接暴力枚举选哪个

时间复杂度为调和级数$O(klogn)$

#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#define LL long long
using namespace std;
const LL MAXN = 1e6 + 10, INF = 1e18 + 10;
inline int read() {char c = getchar(); int x = 0, f = 1;while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();return x * f;
}
int N, M, K;
int block[MAXN], sum[MAXN], a[MAXN], cnt[MAXN];
main() {N = read(); M = read(); K = read();for(int i = 1; i <= M; i++) block[read()] = 1;if(block[0]) {printf("-1"); return 0;}for(int i = 1; i <= K; i++) a[i] = read();int mx = 0;for(int i = 1, j; i <= 1e6; i = j + 1) {j = i; int num = 0;while(block[j]) mx = max(cnt[j] = ++num, mx), j++;}LL out = INF;for(int i = mx + 1; i <= K; i++) {LL now = 0, spend = 0;while(now < N) {if(block[now]) now = now - cnt[now];else now = now + i, spend = spend + a[i];}out = min(out, spend);}printf("%lld", out == INF ? -1 : out);
}

E

总结

第一次打cf,确实有很多不适应的地方,第一题上来把$n$和$m$看反了,然后特判的时候写的是$M % N$,直接wa到飞

T2秒的比较快

T3也秒的比较快,不过写代码的时候把$)($判成了$()$,又wa成傻逼。

T4没看,不过zbq秒了(不过他考场上没判$n=3$..),然后赛后做了做

T5最后几分钟看了看,当时感觉比较可做,但是思路一直纠结在如何处理障碍上,我一直以为障碍的范围是$10^9$然后纠结要不要开map

怎么说呢,感觉自己最近真的太浮躁了,很多时候连范围都没看清楚就开始做。

希望自己往后打cf的时候能沉下心来一句一句的读题目吧。

转载于:https://www.cnblogs.com/zwfymqz/p/9165354.html

Educational Codeforces Round 45 (Rated for Div. 2)相关推荐

  1. Educational Codeforces Round 45 (Rated for Div. 2) A Commentary Boxes

    题目描述: A 评论框 波兰足球杯很快就要来了.来自世界各地的评论员将会参加到这个大事件中. 组织者已经建立了n个评论框,m个地方代表团将会到达世界杯.每个代表 将会获得相同数量的评论框.如果任意一个 ...

  2. Educational Codeforces Round 45 (Rated for Div. 2) D Graph And Its Complement(图的构造)

    题意:构造一个图,使这个图的连通分量有a个,其补图的连通分量有b个,输出邻接矩阵 可以推出当min(a,b)!=1时输出no a=b=1且n=2或者n=3时也为no 其余只要把一个连通分量里的x个点用 ...

  3. Educational Codeforces Round 90 (Rated for Div. 2)(A, B, C, D, E)

    Educational Codeforces Round 90 (Rated for Div. 2) Donut Shops 思路 分三种情况: a==c/ba == c / ba==c/b这个时候两 ...

  4. Educational Codeforces Round 104 (Rated for Div. 2) A,B,C,D,E

    Educational Codeforces Round 104 (Rated for Div. 2) A,B,C,D,E A - Arena 题意 nnn 个英雄,他们的等级分别是 a1,a2,-, ...

  5. Educational Codeforces Round 114 (Rated for Div. 2) (A ~ F)全题解

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Educational Codeforces Round 114 (Rated for Div. 2) ...

  6. Educational Codeforces Round 106 (Rated for Div. 2)(A ~ E)题解(每日训练 Day.16 )

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 Educational Codeforces Round 106 (Rated for Div. ...

  7. Educational Codeforces Round 37 (Rated for Div. 2) 1

    Educational Codeforces Round 37 (Rated for Div. 2) A.Water The Garden 题意:Max想给花园浇水.花园可被视为长度为n的花园床,花园 ...

  8. Educational Codeforces Round 89 (Rated for Div. 2)(A, B, C, D)

    Educational Codeforces Round 89 (Rated for Div. 2) A. Shovels and Swords 思路 题意非常简单,就是得到最多的物品嘛,我们假定a, ...

  9. Educational Codeforces Round 114 (Rated for Div. 2) D. The Strongest Build 暴力 + bfs

    传送门 文章目录 题意: 思路: 题意: 你有nnn个装备槽,每个槽里面有cic_ici​个力量加成,对于每个槽只能选一个力量加成,现在给你mmm个力量组合[b1,b2,...,bn][b_1,b_2 ...

  10. Educational Codeforces Round 72 (Rated for Div. 2) D. Coloring Edges dfs树/拓扑找环

    传送门 文章目录 题意: 思路: 题意: 给你一张图,你需要给这个图的边染色,保证如果有环那么这个环内边的颜色不全相同,输出染色方案和用的颜色个数. n,m≤5e3n,m\le5e3n,m≤5e3 思 ...

最新文章

  1. NEON在Android中的使用举例
  2. 23,148,855,308,184,500是一个神奇的数字,还是纯粹的机会?
  3. C# .net 下拉框显示提示内容-【ComboBox】
  4. Hyperopt 入门指南
  5. 小白的CMMI3体验
  6. jdk1.7安装过程
  7. openURL的使用(iOS调用系统电话、浏览器、地图、邮件等)
  8. php学生选课系统设计网站作品
  9. 如何安全地创建嵌套目录?
  10. window10系统下载软件教程
  11. CAD迷你看图软件中怎么进行实时缩放建筑图纸的大小?
  12. RC有源滤波器之低通滤波器(一)
  13. USB C口5V输入,四节串联锂电池充电管理芯片,IC电路板PW4405芯片-22号电路板
  14. Unity使用Animator.CrossFade后,脚本的OnExitState函数还执行吗
  15. ASM的普通盘转AFD
  16. 存储器之主存--Cache--辅存大全
  17. 【定时任务】- 基础篇
  18. R数据挖掘 第四篇:OLS回归分析
  19. U盘插入Mac电脑无反应什么原因?用NTFS for Mac解决简直人生开了挂!
  20. vasp测试计算机,求助:无法判断vasp测试是否完成

热门文章

  1. 实现了一个本地版本的在线json测试环境光-pythono
  2. freebsd mysql utf8_FreeBSD环境下Mysql问题解决方法集锦
  3. web在session设置的账户用户名显示为空_海蜘蛛路由Web认证怎么设置 海蜘蛛路由Web认证方法【介绍】...
  4. 带存储功能的计算器是什么样的_19年中级会计考生能不能带计算器考试?今天统一回复!...
  5. linux容器返回宿主机,Linux下Docker容器访问宿主机网络
  6. python之父名言_Python之父:为什么操作符很有用?
  7. Spring源码解读(1)-IOC容器BeanDefinition的加载
  8. Java 集合系列Stack详细介绍(源码解析)和使用示例
  9. 转 Java笔记:Java内存模型
  10. HTMLTestRunner修改Python3的版本