CodeForces Round #545 Div.2
A. Sushi for Two
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + ;
int N, cnt = ;
int a[maxn], vis[maxn]; int main() {
scanf("%d", &N);
for(int i = ; i <= N; i ++)
scanf("%d", &a[i]); int l = , r = ;
while(l <= N && r <= N) {
while(a[l] == a[r] && r <= N) vis[cnt] ++, r ++;
cnt ++;
l = r;
} int maxx = ;
for(int i = ; i < cnt - ; i ++) {
int t = min(vis[i], vis[i + ]);
maxx = max(t * , maxx);
} printf("%d\n", maxx);
return ;
}
B. Circus
代码:
#include <bits/stdc++.h>
using namespace std; const int maxn = 1e5 + ;
int N;
string s, t;
int A, B ,C, D;
int a, b, c, d; int main() {
scanf("%d", &N);
cin >> s >> t;
for(int i = ; i < N; i ++) {
if(s[i] == '') {
if(t[i] == '') A ++;
else B ++;
} else {
if(t[i] == '') C ++;
else D ++;
}
} bool flag = false;
for(a = ; a <= A && a <= N / ; a ++) {
int t1 = a + B + D - N / ;
if(t1 >= && t1 <= N / && t1 <= D) {
d = t1; for(b = ; b <= B && b <= N / ; b ++) {
int t2 = N / - a - b - d;
if(t2 >= && t2 <= C && t2 <= N / ) {
c = t2;
flag = true;
break;
}
}
if(flag) break;
}
} if(flag) {
vector<int> ans;
for(int i = ; i < N; i ++) {
if(s[i] == '') {
if(a && t[i] == '') {
ans.push_back(i + );
a --;
} else if(b && t[i] == '') {
ans.push_back(i + );
b --;
}
} else {
if(c && t[i] == '') {
ans.push_back(i + );
c --;
} else if(d && t[i] == '') {
ans.push_back(i + );
d --;
}
}
} for(int i = ; i < ans.size(); i ++)
printf("%d%s", ans[i], i != ans.size() - ? " " : "\n"); } else printf("-1\n"); return ;
}
D. Camp Schedule
D 很简单的 KMP 求出来 nx[t.length()] 然后求出来最小循环节 先把最小循环节前面的部分输出然后输出最小循环节最后把剩下的输出 我是。。真滴不想写了
CodeForces Round #545 Div.2的更多相关文章
- Codeforces Round #545 (Div. 1) 简要题解
这里没有翻译 Codeforces Round #545 (Div. 1) T1 对于每行每列分别离散化,求出大于这个位置的数字的个数即可. # include <bits/stdc++.h&g ...
- Codeforces Round #545 (Div. 2) D 贪心 + kmp
https://codeforces.com/contest/1138/problem/D 题意 两个01串s和t,s中字符能相互交换,问最多能得到多少个(可交叉)的t 题解 即将s中的01塞进t中, ...
- Codeforces Round #545 (Div. 1) Solution
人生第一场Div. 1 结果因为想D想太久不晓得Floyd判环法.C不会拆点.E想了个奇奇怪怪的set+堆+一堆乱七八糟的标记的贼难写的做法滚粗了qwq靠手速上分qwqqq A. Skyscraper ...
- Codeforces Round #545 (Div. 2) D
链接:http://codeforces.com/contest/1138/problem/D 啊啊啊啊啊啊,自闭啊,比赛的时候判断条件 if(s1[i-1]=='0') aa++;写成了 if(s1 ...
- Codeforces Round #545 (Div. 2)(D. Camp Schedule)
题目链接:http://codeforces.com/contest/1138/problem/D 题目大意:给你两个字符串s1和s2(只包含0和1),对于s1中,你可以调换任意两个字符的位置.问你最 ...
- Codeforces Round #545 (Div. 2)(B. Circus)
题目链接:http://codeforces.com/contest/1138/problem/B 题目大意:贼绕口的题目,就是给你两个字符串s1,s2,然后每一个人代表一列,第一列代表技能一每个人是 ...
- Codeforces Round #545 (Div. 2) E 强连通块 + dag上求最大路径 + 将状态看成点建图
https://codeforces.com/contest/1138/problem/E 题意 有n个城市(1e5),有m条单向边(1e5),每一周有d天(50),对于每个城市假如在某一天为1表示这 ...
- Codeforces Round #545 (Div. 2) 交互 + 推公式
https://codeforces.com/contest/1138/problem/F 题意 有一条长为t的链,一个长为c的环,定义终点为链和环相连环上的第一个点,现在有10个人在起点,你每次可以 ...
- Codeforces Round #545 (Div. 2)-Camp Schedule
题目要求,给定一个s序列,一个p序列,问能不能对s做相应的调整,使得s序列中,有尽可能多的p子串(可以重复) 最开始我拿到这个题目,也是一点头绪都没有,如何做调整呢? 首先考虑如何会有尽可能多的子串, ...
随机推荐
- EF三种编程方式的区别Database first ,Model first ,code first
首先对于EF中先出现的datebase first和model first两种编程方式,其的区别根据字面意思很容易能够理解. datebase first就是代表数据库优先,那么前提就是先创建数据 ...
- python3中json模块的用法
__author__ = "JentZhang" import json user_info = {"} # 将字典转换为JSON字符串 json_str = json. ...
- C#调用Oracle的存储过程时,连接字符串需要配置PLSQLRSet=1
C#调用Oracle的存储过程时, 如果有个SYS_REFCURSOR的Output参数存储时, web.config文件中的连接字符串需要配置PLSQLRSet=1, 否则可能会报这个错:参数个数或 ...
- Java开发笔记(三十一)字符类型的表达
前面介绍的Java编程,要么是与数字有关的计算,要么是与逻辑有关的推理,充其量只能实现计算器和状态机.若想让Java运用于更广阔的业务领域,就得使其支撑更加血肉丰满的业务场景,而丰满的前提是能够表达大 ...
- Java学习笔记 抽象类 接口 多态
instanceof 对象名 instanceof 类名 该对象是否属于该类 Animal animal = new Dog(); if(animal instanceof Dog){ Dog d = ...
- vue2.x 下载后台传过来的流文件(excel)后乱码问题
1.接口返回的流和头部: 2.下载流文件的代码 方法一:是用了插件 https://github.com/kennethjiang/js-file-download 方法二:是用了 blob 不管哪种 ...
- vue HTTP 请求(vue-resource)
来自:https://www.cnblogs.com/lhl66/p/8022423.html 侵删 //初始化页面需要做什么事情 //点击后需要做什么事情 //鼠标.键盘.冒泡.默认行为等事件 // ...
- loj#2531. 「CQOI2018」破解 D-H 协议(BSGS)
题意 题目链接 Sol 搞个BSGS板子出题人也是很棒棒哦 #include<bits/stdc++.h> #define Pair pair<int, int> #defin ...
- #WEB安全基础 : HTML/CSS | 0x4.1嵌套列表
如果你认为列表只有ul和ol那你就错了 我要为你展示新的列表 这次只有一个index.html文件 这是它的效果 以下是它的代码 <html> <head> <title ...
- 使用ethtool显示硬件PHY信息
1.总结: 使用ethtool 可以查看端口的phy配置 2.显示端口配置 [root@localhost zhou]# ethtool ens33Settings for ens33: Suppor ...