传送门

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. (三)React Ant Design Pro + .Net5 WebApi:后端环境搭建

    一. 简介 1. 平常用的core webapi 3.1,恰逢.Net5.0正式版发布了,直接开整. 2. 先学习IdentityServer4 .Autofac.EF Core,集成到后台框架里. ...

  2. 【Linux】awk想打印制定列以后的所有列

    今天偶然研究awk,有一个文件,文件内容是全篇的1 2 3 4 5 6 7 8 9 0 现在想打印除了第一列意外的所有列 文件内容: [root@localhost ~]# cat test.txt ...

  3. Centos7下安装MySQL8.0.23-小白的开始

    首先简单介绍一下什么叫MySQL: 数据库简而言之就是存储数据的仓库,为了方便数据的存储和管理,它将数据按照特定的规律存储在磁盘上.是为了实现一定的目的,按照某种规则组织起来的数据的集合: MySQL ...

  4. 给HTML页面设置自己的icon

    原因: 不知道为什么,SpringBoot中自动设置icon失效了. 解决方法: 在head标签中添加自己想要使用的icon图片.后缀使用图片格式,不要使用.ico. <link href=&q ...

  5. .net code+vue 文件上传

    后端技术 .net code 官方文档 https://docs.microsoft.com/zh-cn/aspnet/core/mvc/models/file-uploads?view=aspnet ...

  6. 在HDFS中将文件从源路径移动到目的路径。

    import java.text.SimpleDateFormat; import java.util.Scanner; import org.apache.hadoop.fs.FSDataInput ...

  7. 就是通过事件方法,在window.loaction.href里追加了参数字符串

    参考博文:https://www.kancloud.cn/digest/yvettelau/137669

  8. 不识Netty真面目,只缘未读此真经

    Netty官网:https://netty.io/ Netty is an asynchronous event-driven network application framework for ra ...

  9. 大型面试现场:一条update sql执行都经历什么?

    导读 Hi,大家好!我是白日梦!本文是MySQL专题的第 24 篇. 今天我要跟你分享的MySQL话题是:"从一条update sql执行都经历什么开始,发散开一系列的问题,看看你能抗到第几 ...

  10. Spring Boot构建 RESTful 风格应用

    Spring Boot构建 RESTful 风格应用 1.Spring Boot构建 RESTful 风格应用 1.1 实战 1.1.1 创建工程 1.1.2 构建实体类 1.1.4 查询定制 1.1 ...