A. Cancel the Trains

题意:给定两个数组,找出这两个数组中有多少重复元素,然后输出

思路:直接找

代码:

 1 #include<iostream>
2 #include<algorithm>
3 #include<cstdio>
4 #include<cmath>
5 #include<cstring>
6 #include<map>
7 #include<queue>
8 using namespace std;
9 const int maxx=2e5+10;//14.12
10 int main(){
11 int n;
12 scanf("%d",&n);
13 while(n--){
14 int a[150]={0};
15 int b[150]={0};
16 int m,k;
17 scanf("%d %d",&m,&k);
18 for(int i=0;i<m;i++){
19 int num;
20 scanf("%d",&num);
21 a[num]++;
22 }
23 for(int j=0;j<k;j++){
24 int num;
25 scanf("%d",&num);
26 b[num]++;
27 }
28 int sum=0;
29 for(int i=0;i<150;i++){
30 if(a[i]>0&&b[i]>0){
31 sum++;
32 }
33 }
34 printf("%d\n",sum);
35 }
36 }

B. Suffix Operations

题目及解题见:一道codeforces题引发的差分学习

C. Triangles(思维题)

题意:题目中已知矩阵及其矩阵上的数字(从0-9),问最大面积的三角形:1.0-9各个数字分别构成的最大的三角形,保证顶点上是其对应的数字;2.可以替换掉矩阵中任意一个数字,把它变成任意一个数字;3.保证三角形的一个边和是水平的或者竖直的,输出各个数构成三角形的最大面积值

思路:构造,让其一个点是定住的,找到此数能到达的最大位置x和最小的位置x(纵坐标不一定相等)然后竖直方向直接改变进行变换,让其成为被改变的那个数,这样就和竖直方向平行了。水平方向的计算也是如此

代码:

 1 #include<iostream>
2 #include<cstdio>
3 #include<cmath>
4 #include<cstring>
5 #include<algorithm>
6 #include<map>
7 using namespace std;
8 //const int maxxx=1e5+10;
9 int maxx[20]={0},maxy[20]={0},minx[20],miny[20],c[50]={0};
10 int ans[50]={0},p[2500][2500];
11 int main(){
12 int t;
13 scanf("%d",&t);
14 while(t--){
15 int n;
16 scanf("%d",&n);
17
18 for(int i=0;i<10;i++){
19 minx[i]=n+1;
20 miny[i]=n+1;
21 maxx[i]=0;
22 maxy[i]=0;
23 c[i]=0;
24 ans[i]=0;
25 }
26 for(int i=1;i<=n;i++){
27 for(int j=1;j<=n;j++){
28 scanf("%1d",&p[i][j]);
29 int xx=p[i][j];
30 c[xx]++;
31 maxx[xx]=max(maxx[xx],i);
32 maxy[xx]=max(maxy[xx],j);
33 minx[xx]=min(minx[xx],i);
34 miny[xx]=min(miny[xx],j);
35 }
36 }
37 for(int i=1;i<=n;i++){
38 for(int j=1;j<=n;j++){
39 int xx;
40 xx=p[i][j];
41 if(c[xx]<2){
42 continue;
43 }
44 int dx=max(i-minx[xx],maxx[xx]-i);
45 int dy=max(j-miny[xx],maxy[xx]-j);
46 ans[xx]=max(ans[xx],dx*(max(j-1,n-j)));
47 ans[xx]=max(ans[xx],dy*(max(i-1,n-i)));
48 }
49 }
50 for(int i=0;i<10;i++){
51 printf("%d",ans[i]);
52 if(i<9){
53 printf(" ");
54 }
55 }
56
57 printf("\n");
58 }
59 }

Codeforces Round #688 (Div. 2)的更多相关文章

  1. Codeforces Round #688(Div 2) D. Checkpoints

    思路 第一步,先推导1,0,0,--,0,就是1后面跟了n-1个0的时候 所需要的期望步数 封闭式推导 \(f_n\)代表从n关开始直接通关需要的步数的期望 n为1的情况,即就只有一个1 \(f_1= ...

  2. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  3. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  4. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  5. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  6. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  7. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  8. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

  9. Codeforces Round #371 (Div. 1)

    A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...

随机推荐

  1. Windows下解析命令行参数

    linux通常使用GNU C提供的函数getopt.getopt_long.getopt_long_only函数来解析命令行参数. 移植到Windows下 getopt.h #ifndef _GETO ...

  2. 1 [main] DEBUG Sigar - no sigar-amd64-winnt.dll in java.library.path org.hyperic.sigar.SigarException: no sigar-amd64-winnt.dll in java.library.path

    github上一个java项目,在myeclipse中运行正常,生成jar后,运行报错: 1 [main] DEBUG Sigar - no sigar-amd64-winnt.dll in java ...

  3. 3、Spring教程之IOC创建对象方式

    1.通过无参构造方法来创建 1.User.java public class User { private String name; public User() { System.out.printl ...

  4. CentOS离线安装Nginx

    在医院搭建项目环境时,因为医院通常都是内网的,访问不了外网,所以很多服务都得通过离线的方式安装,下面讲讲CentOs系统中如何离线安装Nginx. 安装准备 Nginx离线安装依赖gcc.g++环境, ...

  5. java例题_03 水仙花数

    1 /*3 [程序 3 水仙花数] 2 题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身. 3 例如:153 是一个 ...

  6. Macbook 安装kali linux 双系统 2020.3 超详细

    博主折腾了一星期这东西,到现在都还有些坑没解决(最后面会讲).不过最起码系统装上了,可以用了,看到这桌面惊艳了,再点下左上角表示人间值得. 其实我是装了windos 10.macos 和kali三系统 ...

  7. [图论]剑鱼行动:kruskal

    剑鱼行动 目录 剑鱼行动 Description Input Output Sample Input Sample Output 解析 难点 代码 Description 给出N个点的坐标,对它们建立 ...

  8. 微信小程序授权登录以及用户信息相关接口调整导致授权框不弹出

    前言:4月8号升级了小程序业务后提交了版本并上线.突然一个同事说体验版的点击"登录"按钮无效.当时觉得应该不会呀,这几天一直用手机调试,每天也在不停的登录授权,弹框一直有的呀.然后 ...

  9. Spring Boot入门学习

    1. Spring Boot概述 1.1.什么是Spring Boot SpringBoot是一个可使用Java构建微服务的微框架.是Spring框架及其社区对"约定优先于配置"理 ...

  10. 数据库MySQL二

    注意拼接的时候如果为null则都为null 用if null 1.条件查询 2.按逻辑表达式筛选 3.模糊查询 还有not like 用转义字符\ #2.in 数值型的常量值都不用单引号,非数值型的都 ...