传送门

B题题意:

给你n个数,让你把这n个数分成k个段(不能随意调动元素位置)。你需要保证这k个段里面所有元素加起来的和是一个奇数。问可不可以这样划分成功。如果可以打印YES,之后打印出来是从哪里开始断开的。

否则打印出NO

题解:

加上奇数可以使和的性质改变,原来使偶数则变为奇数,奇数则变为偶数。加上一个偶数就不会有这样的变化。所以第一步就找出来有多少个奇数。因为要保证k个段的和都为奇数,所以每个段得先有一个奇数

剩下来的奇数数量如果是偶数那就不影响,这样就可以成功划分。如果是奇数那就划分不成功

代码:

 1 #include<stdio.h>
2 #include<string.h>
3 #include<iostream>
4 #include<algorithm>
5 #include<map>
6 #include<math.h>
7 using namespace std;
8 typedef long long ll;
9 const int maxn=2e5+5;
10 const int mod=26;
11 const int block=300;
12 int v[maxn];
13 int main()
14 {
15 int t;
16 scanf("%d\n",&t);
17 while(t--)
18 {
19 int n,m,sum=0,a;
20 scanf("%d%d",&n,&m);
21 for(int i=1;i<=n;++i)
22 {
23 scanf("%d",&v[i]);
24 if(v[i]%2)
25 sum++;
26 }
27 sum-=m;
28 if(sum<0)
29 printf("NO\n");
30 else if(sum==0 || sum%2==0)
31 {
32 //sum/=2;
33 printf("YES\n");
34 int i;
35 if(sum==0) i=0;
36 else i=1;
37 if(sum!=0)
38 for(i;i<=n;++i)
39 {
40 if(v[i]%2)
41 {
42 sum--;
43 if(sum==0)
44 break;
45 }
46 }
47 for(i+=1;i<=n;++i)
48 {
49 if(m==1)
50 {
51 printf("%d\n",n);
52 break;
53 }
54 if(v[i]%2)
55 {
56 printf("%d ",i),m-=1;
57 }
58 }
59 }
60 else printf("NO\n");
61 }
62 return 0;
63 }

C题题意:

给你n个机器人,这n个机器人有四个移动方向,但是有可能它的中枢坏了导致不能向某个方向移动。现在你需要找到一个坐标,机器人得到这个坐标会来到这里,但是也有某些方向损坏的机器人来不了

所以你需要找出来有没有能让所有机器人都到达这里的一个坐标。能找出来的话就先打印一个“1”再打印出这个坐标,否则打印出0

题解:

找出来所有机器人可移动区间,再让它们取并集就可以了

代码:

 1 #include<stdio.h>
2 #include<string.h>
3 #include<iostream>
4 #include<algorithm>
5 #include<map>
6 #include<math.h>
7 using namespace std;
8 typedef long long ll;
9 const int maxn=1e5;
10 const int mod=26;
11 const int block=300;
12 struct shudui
13 {
14 int xmin,xmax,ymin,ymax,x,y;
15 } m[maxn+5];
16 int main()
17 {
18 int t;
19 scanf("%d",&t);
20 while(t--)
21 {
22 int xmin=-maxn,xmax=maxn,ymin=-maxn,ymax=maxn,flag=0;
23 int n,x1,x2,x3,x4,x,y;
24 scanf("%d",&n);
25 for(int i=1; i<=n; ++i)
26 {
27 scanf("%d%d%d%d%d%d",&x,&y,&x1,&x2,&x3,&x4);
28 m[i].x=x;
29 m[i].y=y;
30 if(!flag)
31 {
32 if(x1)
33 m[i].xmin=-maxn;
34 else m[i].xmin=x;
35 if(x2)
36 m[i].ymax=maxn;
37 else m[i].ymax=y;
38 if(x3)
39 m[i].xmax=maxn;
40 else m[i].xmax=x;
41 if(x4)
42 m[i].ymin=-maxn;
43 else m[i].ymin=y;
44 if(xmin>m[i].xmax || xmax<m[i].xmin || ymin>m[i].ymax || ymax<m[i].ymin)
45 {
46 flag=1;
47 }
48 else
49 {
50 xmin=max(xmin,m[i].xmin);
51 xmax=min(xmax,m[i].xmax);
52 ymin=max(ymin,m[i].ymin);
53 ymax=min(ymax,m[i].ymax);
54 }
55 }
56 }
57 if(!flag)
58 {
59 printf("1 %d %d\n",xmin,ymin);
60 }
61 else printf("0\n");
62 }
63 return 0;
64 }

Codeforces Round #575 (Div. 3) B. Odd Sum Segments 、C Robot Breakout的更多相关文章

  1. Codeforces Round #575 (Div. 3) B. Odd Sum Segments (构造,数学)

    B. Odd Sum Segments time limit per test3 seconds memory limit per test256 megabytes inputstandard in ...

  2. Codeforces Round #575 (Div. 3) 昨天的div3 补题

    Codeforces Round #575 (Div. 3) 这个div3打的太差了,心态都崩了. B. Odd Sum Segments B 题我就想了很久,这个题目我是找的奇数的个数,因为奇数想分 ...

  3. Codeforces Round #556 (Div. 2) - C. Prefix Sum Primes(思维)

    Problem  Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 1000 mSec Problem Descripti ...

  4. Codeforces Round #575 (Div. 3)

    本蒟蒻已经掉到灰名了(菜到落泪),希望这次打完能重回绿名吧...... 这次赛中A了三题 下面是本蒟蒻的题解 A.Three Piles of Candies 这题没啥好说的,相加除2就完事了 #in ...

  5. Codeforces Round #575 (Div. 3) 题解

    比赛链接:https://codeforc.es/contest/1196 A. Three Piles of Candies 题意:两个人分三堆糖果,两个人先各拿一堆,然后剩下一堆随意分配,使两个人 ...

  6. Codeforces Codeforces Round #319 (Div. 2) B. Modulo Sum 背包dp

    B. Modulo Sum Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/577/problem/ ...

  7. Codeforces Round #344 (Div. 2) E. Product Sum 维护凸壳

    E. Product Sum 题目连接: http://www.codeforces.com/contest/631/problem/E Description Blake is the boss o ...

  8. Codeforces Round #646 (Div. 2) A. Odd Selection(数学)

    题目链接:https://codeforces.com/contest/1363/problem/A 题意 判断是否能从 $n$ 个数中选 $x$ 个数加起来和为奇数. 题解 首先 $n$ 个数中至少 ...

  9. Codeforces Round #238 (Div. 2) D. Toy Sum(想法题)

     传送门 Description Little Chris is very keen on his toy blocks. His teacher, however, wants Chris to s ...

随机推荐

  1. Loadrunner与kylinPET的能力对比测试--web动态请求

    概述 在<性能测试工具选择策略--仿真度对比测评分析报告>一文详细分析了使用相同的web页面,分别使用LoadRunner,Jmeter,kylinTOP工具进行录制脚本并执行得出在静态请 ...

  2. 【Java】集合综合案例 - 播放器管理

    集合综合案例 文章目录 集合综合案例 需求分析 项目演示 详细设计 代码实现 歌曲类 播放器类 播放列表类 测试 参考资料 播放器管理 需求分析 项目演示 详细设计 代码实现 重新搞一波 复习巩固 简 ...

  3. 【System】I/O密集型和CPU密集型工作负载之间有什么区别

    CPU密集型(CPU-bound) CPU密集型也叫计算密集型,指的是系统的硬盘.内存性能相对CPU要好很多,此时,系统运作大部分的状况是CPU Loading 100%,CPU要读/写I/O(硬盘/ ...

  4. 【Android】编译报错 Annotation processors must be explicitly declared now 解决方案

    问题 在网上下载一个demo,因为版本久远,里面添加了本地 Butter Knife 的jar包,在编译时报错 Annotation processors must be explicitly dec ...

  5. 2021年官网下载各个版本JDK最全版与官网查阅方法

    版本说明 1.安装部署JDK (1)环境 (2)官网下载JDK 由于官网的地址会随着时间的修改而更改修改下载地址,现在讲述下通用的界面操作下载JDK,以后JDK收费更严重,估计就只能下载开源的了. A ...

  6. /bin/sh: cc: command not found

    make的时候报错:/bin/sh: cc: command not found 解决: 1. sudo yum -y install gcc gcc-c++ libstdc++-devel 2. m ...

  7. ESXI6.7主机降级至ESXI6.5

    上一条博客vcenter添加主机失败:https://www.cnblogs.com/Crazy-Liu/p/11211760.html 原因esxi主机和vcenter版本不一致,因为vcenter ...

  8. 关于redis搭建环境

    首先,window键+r 输入cmd进入dos命名窗口,我的redis是装在了d盘,so我得输入cd:或者d:进入d盘,cd\redis文件夹路径,这样的话,直接输入  redis-server -- ...

  9. Convert a string into an ArrayBuffer

    https://github.com/mdn/dom-examples/blob/master/web-crypto/import-key/spki.js How to convert ArrayBu ...

  10. linux 文件结构体和文件描述符号的学习

    https://blog.csdn.net/cywosp/article/details/38965239