最近网课也开始了,牛客上一堆比赛题目也没补,所以就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. js+vue、纯js 按条件分页

    听说大牛都从博客开始的... 人狠话不多,翠花上酸菜代码: 有注解基本上都看的懂!但是自己还是要注意以下几点,免得以后再浪费时间. #.vue 中监听事件 v-on:change=“vueChange ...

  2. Javascript 基础学习(四)js 的语句

    由于程序都是自上向下的顺序执行的,所以通过流程控制语句可以改变程序执行的顺序,或者反复的执行某一段的程序. 语句的分类 条件判断语句 条件分支语句 循环语句 条件判断语句 条件判断语句也称为if语句 ...

  3. Linux安装Redis、后台运行、系统自启动

    Redis是用C语言编写的开源免费的高性能的分布式内存数据库,基于内存运行并支持持久化的NoSQL数据库. 安装 1)从官网http://download.redis.io/releases/下载re ...

  4. winform重绘控件边框

    首先添加一个用户控件 对于重绘边框有三个需要考虑的东西 1:是否显示边框 2:边框颜色 3:边框宽度 所以定义三个私有变量 /// <summary>/// 是否显示边框/// </ ...

  5. 【Java】简易Socket连接实现

    客户端: import java.io.*; import java.net.Socket; import java.text.SimpleDateFormat; import java.util.D ...

  6. JavaScript使用MQTT

    1.MQTT Server使用EMQTTD开源库,自行安装配置: 2.JS使用Websocket连接通信. 3.JS的MQTT库为paho-mqtt,git地址:https://github.com/ ...

  7. idea中创建maven的Javaweb工程并进行配置

    学完maven后,可以创建maven的javaweb工程,在创建完成后还需要一些配置,下面来说下具体步骤,在这里我创建的是一个模块,创建web项目的方式和创建模块一样 1.创建一个模块,点new-Mo ...

  8. SVN使用经验

    转载于:Svn发布项目 个人使用体验: 关于svn的相关命令 从服务器检出创建的项目文件夹,向项目中添加文件,右键tortoiseSvn->add 然后右键SVN Commit,选择文件并输入提 ...

  9. SQL JOIN 的解析

    1.SQL语句结构 select  distinct  < select_list > from  < left_table > < join_type > joi ...

  10. P1028 数的计算( 记忆剪枝 )

    题目描述 我们要求找出具有下列性质数的个数(包含输入的自然数 n ): 先输入一个自然数 n(n≤1000),然后对此自然数按照如下方法进行处理: 不作任何处理; 在它的左边加上一个自然数,但该自然数 ...