最近网课也开始了,牛客上一堆比赛题目也没补,所以就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. pycharm(迅雷下载链接)

    pycharm2020迅雷下载链接: https://download.jetbrains.com/python/pycharm-professional-2019.3.3.exe?_ga=2.146 ...

  2. 关于广州xx公司对驰骋BPM, 流程引擎表单引擎 常见问题解答

    关于广州xx公司对驰骋BPM, 流程引擎表单引擎 常见问题解答 @驰骋工作流,ccflow周朋 周总早, ccflow 功能很强大,在体验过程中,以下几个问题需沟通下: 先使用.net 再使用java ...

  3. beego orm的使用

    在使用beego model 去操作数据库时 有一些疑惑  找到了一个比较好的博文 原文地址 : https://my.oschina.net/u/252343/blog/829912 (Kelvin ...

  4. 有多少人在面试时,被Java 如何线程间通讯,问哭了?

    正常情况下,每个子线程完成各自的任务就可以结束了.不过有的时候,我们希望多个线程协同工作来完成某个任务,这时就涉及到了线程间通信了. 本文涉及到的知识点: thread.join(), object. ...

  5. EF Core For Oracle11中Find FirstOrDefault等方法执行失败

    问题描述 最近在使用ef core连接oracle的发现Find.FirstOrDefault.Skip Task分页等等方法执行失败.使用的是docker安装的oracle11,错误如下图: 解决办 ...

  6. 基于element-ui 模仿微信聊天页面以及滚动条隐藏在chrome和其他浏览器的处理

    1.效果图 2.代码 <template> <div style=" overflow: hidden;"> <el-row> <el-c ...

  7. AE神奇插件TypeMonkey—抖音点赞100W+的文字视频特效是如何做出来的?

    现在最火的东西,短视频必须要拥有姓名啦,抖音这些短视频平台风头正盛,我们也常常在上面看到一些文字动画Vlog,看着并不复杂,但是有些却有上百万的点击量,今天介绍的一款神奇插件——TypeMonkey, ...

  8. Vue中echarts的使用

    1.安装 npm install echarts --save 2. 导入并挂载 <template>   <!-- 1. 为ECharts准备一个具备大小(宽高)的Dom --&g ...

  9. 如何开发自己的第一个 Serverless Component

    前言 上一篇 基于 Serverless Component 的全栈解决方案 介绍 Serverless Component 是什么和如何使用 Serverless Component 开发一个全栈应 ...

  10. P3292 [SCOI2016]幸运数字 [线性基+倍增]

    线性基+倍增 // by Isaunoya #include <bits/stdc++.h> using namespace std; #define rep(i, x, y) for ( ...