最近网课也开始了,牛客上一堆比赛题目也没补,所以就D题后面的也懒得补了

A.Three String

水题

#include <cstdio>
#include <cstring>
using namespace std;
char a[], b[], c[];
int main() {
int t;
scanf("%d", &t);
while (t--) {
memset(a, , sizeof(a));
memset(b, , sizeof(b));
memset(c, , sizeof(c));
scanf("%s%s%s", a, b, c);
int len = strlen(a), ans = ;
for (int i = ; i < len; i++) {
if (c[i] == a[i] || c[i] == b[i])
continue;
ans = -;
break;
}
if (ans == -)
puts("NO");
else
puts("YES");
}
return ;
}

B.Motarack's Birthday

其实也挺水的...但是我场上脑子有点问题,第一反应是三分(?)因为它应该是只有一个极值的函数,可以用三分来做

这是我的代码,写的很复杂而且很奇怪

#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const int N = 1e5 + ;
int a[N], n;
inline int val(int b) {
int maxn = ;
for (int i = ; i <= n; i++) {
if (a[i - ] == - && a[i] == -)
continue;
if (a[i - ] == -)
maxn = max(maxn, (int)abs(b - a[i]));
else if (a[i] == -)
maxn = max(maxn, (int)abs(b - a[i - ]));
else
maxn = max(maxn, (int)abs(a[i] - a[i - ]));
}
return maxn;
}
int main() {
int t;
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
for (int i = ; i <= n; i++)
scanf("%d", &a[i]);
int l = , r = 1e9;
while (r - l >= ) {
int l1 = l + (r - l) / ;
int r1 = r - (r - l) / ;
int a = val(l1), b = val(r1);
if (a <= b)
r = r1;
else
l = l1;
}
int a, b = 1e9 + ;
if (l != r) {
for (int i = l; i <= r; i++) {
int z = val(i);
if (z < b)
b = z, a = i;
}
}
else
a = l, b = val(l);
printf("%d %d\n", b, a);
}
return ;
}

然后题解肯定不是这样的啦,最后答案的范围肯定在和-1相邻的数字之间,若这些数字中最大的是maxn, 最小的是minn,则差的最大就是max(abs(maxn - val), abs(minn - val)),所以val等于(maxn + minn)/2就行了,代码很简单,我也懒得写了。

C.Ayoub's function

场上想了很久(还是太菜了),后来突然灵机一动,想到可以用总数减去只有0的个数,然后就可以发现000...000的序列越短越好,然后就可以直接O(1)出来了。

#include <cstdio>
using namespace std;
int main() {
int t;
scanf("%d", &t);
while (t--) {
long long n, m;
scanf("%lld %lld", &n, &m);
long long ans = 1ll * n * ( + n) / ;
if ((n - m) % (m + ) == ) {
long long b = (n - m) / (m + );
ans -= 1ll * (m + ) * b * (b + ) / ;
}
else {
long long b = (n - m) / (m + );
long long c = (n - m) % (m + );
ans -= (m + - c) * b * (b + ) / ;
ans -= c * (b + ) * (b + ) / ;
}
printf("%lld\n", ans);
}
return ;
}

D.Time to Run

很容易发现它是欧拉通路,因为它没有奇度顶点,然后想一个构造的方法就行了,然后我就随便想了一个,结果有一堆细节上的问题QAQ

#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
int n, m, k;
scanf("%d %d %d", &n, &m, &k);
int r = * m * n - * n - * m;
if (k > r) {
puts("NO");
return ;
}
puts("YES");
n--; m--;
//RDU
if (k == )
return ;
if (n == ) { //这种情况要特殊考虑
if (k <= m) {
puts("");
printf("%d R\n", k);
}
else {
puts("");
printf("%d R\n%d L", m, k - m);
}
return ;
}
if (m == ) { //同上
if (k <= n)
printf("1\n%d D\n", k);
else
printf("2\n%d D\n%d U\n", n, k - n);
return ;
}
int kk = k;
int t = , cnt = ;
while (k > ) { //第一遍先找要多少次操作
if (t == (n + )) {
if (k <= m) {
cnt++;
break;
}
else {
cnt++;
k -= m;
}
if (k <= m) {
cnt++;
break;
}
else {
cnt++;
k -= m;
}
if (k <= n) {
cnt++;
break;
}
else {
cnt++;
k -= m;
}
break;
}
if (k <= m * ) {
if (k / > )
cnt++;
int y = k % ;
if (y == )
cnt++;
else if (y == )
cnt++;
break;
}
else {
cnt++;
k -= m * ;
}
if (k <= m) {
cnt++;
break;
}
else {
cnt++;
k -= m;
}
cnt++;
k--;
t++;
}
t = ;
k = kk;
printf("%d\n", cnt);
while (k > ) {
if (t == (n + )) { //这个要注意,最后一行就要往回走
if (k <= m) {
printf("%d R\n", k);
break;
}
else {
printf("%d R\n", m);
k -= m;
}
if (k <= m) {
printf("%d L\n", k);
break;
}
else {
printf("%d L\n", m);
k -= m;
}
if (k <= n) {
printf("%d U\n", k);
break;
}
else {
printf("%d U\n", m);
k -= m;
}
break;
}
if (k <= m * ) {
if (k / > )
printf("%d RDU\n", k / );
int y = k % ;
if (y == )
puts("1 R");
else if (y == )
puts("1 RD");
break;
}
else {
printf("%d RDU\n", m);
k -= m * ;
}
if (k <= m) {
printf("%d L\n", k);
break;
}
else {
printf("%d L\n", m);
k -= m;
}
printf("1 D\n");
k--;
t++;
}
return ;
}

Codeforces Round #619 (Div. 2) A~D题解的更多相关文章

  1. Codeforces Round #612 (Div. 2) 前四题题解

    这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...

  2. Codeforces Round #198 (Div. 2)A,B题解

    Codeforces Round #198 (Div. 2) 昨天看到奋斗群的群赛,好奇的去做了一下, 大概花了3个小时Ak,我大概可以退役了吧 那下面来稍微总结一下 A. The Wall Iahu ...

  3. Codeforces Round #672 (Div. 2) A - C1题解

    [Codeforces Round #672 (Div. 2) A - C1 ] 题目链接# A. Cubes Sorting 思路: " If Wheatley needs more th ...

  4. Codeforces Round #614 (Div. 2) A-E简要题解

    链接:https://codeforces.com/contest/1293 A. ConneR and the A.R.C. Markland-N 题意:略 思路:上下枚举1000次扫一遍,比较一下 ...

  5. Codeforces Round #610 (Div. 2) A-E简要题解

    contest链接: https://codeforces.com/contest/1282 A. Temporarily unavailable 题意: 给一个区间L,R通有网络,有个点x,在x+r ...

  6. Codeforces Round #611 (Div. 3) A-F简要题解

    contest链接:https://codeforces.com/contest/1283 A. Minutes Before the New Year 题意:给一个当前时间,输出离第二天差多少分钟 ...

  7. Codeforces Round #499 (Div. 2) D. Rocket题解

    题目: http://codeforces.com/contest/1011/problem/D This is an interactive problem. Natasha is going to ...

  8. Codeforces Round #499 (Div. 2) C Fly题解

    题目 http://codeforces.com/contest/1011/problem/C Natasha is going to fly on a rocket to Mars and retu ...

  9. Codeforces Round #198 (Div. 2)C,D题解

    接着是C,D的题解 C. Tourist Problem Iahub is a big fan of tourists. He wants to become a tourist himself, s ...

随机推荐

  1. StarUML之九、starUML的一些特殊属性的说明

    UML的扩充性机制允许你在控制的方式下扩充UML语言. 这一类的机制包括:stereotype,标记值.约束. Stereotype扩充了UML的词汇表,允许你创建新的建筑块,这些建筑块从已有的继承而 ...

  2. 89组合margin、padding、float、clear问题

    有关css外边距margin和内边距padding样式,简而述之,顺时针方向旋转,按照上右下左读取,margin-top:/*距离上边距*/margin-right:/*距离右边距*/margin-b ...

  3. djinn:1 Vulnhub Walkthrough

    靶机下载链接: https://download.vulnhub.com/djinn/djinn.ova 主机端口扫描: FTP发现一些文件提示 1337端口是一个游戏,去看下 哈哈有点难,暂时放弃, ...

  4. cesium结合geoserver实现地图空间查询(附源码下载)

    前言 cesium 官网的api文档介绍地址cesium官网api,里面详细的介绍 cesium 各个类的介绍,还有就是在线例子:cesium 官网在线例子,这个也是学习 cesium 的好素材. 内 ...

  5. 刷题84. Largest Rectangle in Histogram

    一.题目说明 题目84. Largest Rectangle in Histogram,给定n个非负整数(每个柱子宽度为1)形成柱状图,求该图的最大面积.题目难度是Hard! 二.我的解答 这是一个 ...

  6. VAE

    Waiting list: basic knowledge: http://adamlineberry.ai/vae-series/vae-code-experiments

  7. zabbix默认监控负载取值不准确

    今天碰到个负载高引起的问题但是查看zabbix监控并没有报警,检查后发现监控取值与实际服务器内负载不一致. 使用zabbix_get命令在服务器内测试 zabbix默认模板键值 取值内容 [root@ ...

  8. CF #619 div.2

    序 希望,不要还有一天像今天一样糟糕. T1 three strings 笔记本的google 炸了,读题可难受了 多组测试数据 我们的想法是,用string存字符串,若 对于任意的i,a[i],b[ ...

  9. 吴裕雄--天生自然 python开发学习笔记:Git安装配置流程

  10. 深度优先搜索DFS---全球变暖

    内心OS:这道题是去年准备HD复试时,我用来练习DFS的.现在再做这道题,感触颇深,唉,时光蹉跎,物是人非啊~~ 题目: 你有一张某海域NxN像素的照片,”.”表示海洋.”#”表示陆地,如下所示: … ...