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. 数字转人民币读法-python3

    """ 2 把一个浮点数分解成证书备份和小数部分 3 """ 4 def divide(num): 5 intnum = int(num) ...

  2. 电影AI修复,让重温经典有了新的可能

    摘要:有没有一种呈现,不以追求商业为第一目的,不用花大价钱,不用翻拍,没有画蛇添足,低成本的可共赏的让经典更清晰? 本文分享自华为云社区<除了重映和翻拍,重温经典的第三种可能>,原文作者: ...

  3. thinkphp 5.1框架利用及rce分析

    前言 上个学期钻研web渗透的时候接触过几个tp的框架,但那时候还没有写blog的习惯,也没有记录下来,昨天在做ctf的时候正好碰到了一个tp的框架,想起来就复现一下 正文 进入网站,标准笑脸,老tp ...

  4. 一文读懂MySql主从复制机制

    作为一个关系型数据库,MySQL内建地提供数据复制机制,这使得在使用时,可以基于其复制机制实现高可用架构等高级特性,从而使得MySQL无需借助额外的插件或其他工具就具备适用于生产环境.这是MySQL得 ...

  5. 基于ceph rbd 在kubernetes harbor 空间下创建动态存储

    [root@bs-k8s-ceph ~]# ceph osd pool create harbor 128 Error ETIMEDOUT: crush test failed with -110: ...

  6. 小白都能学会的Java注解与反射机制

    前言 Java注解和反射是很基础的Java知识了,为何还要讲它呢?因为我在面试应聘者的过程中,发现不少面试者很少使用过注解和反射,甚至有人只能说出@Override这一个注解.我建议大家还是尽量能在开 ...

  7. [DFS]特殊的质数肋骨

    特殊的质数肋骨 时间限制:1000MS----内存限制:256000KB 题目描述 农民约翰母牛总是产生最好的肋骨. 你能通过农民约翰和美国农业部标记在每根肋骨上的数字认出它们. 农民约翰确定他卖给买 ...

  8. c++排序相关的参数“cmp“的用法及理解

    对sort函数(需要algorithm头文件),它的cmp可以是"函数",也可以是"对象" bool myfunction (int i,int j) { re ...

  9. MySQL数据库高级五:主从复制

    主机只能一台 从机去复制 单表500万上限

  10. day-7 xctf-level2

    xctf-level2 题目传送门:https://adworld.xctf.org.cn/task/answer?type=pwn&number=2&grade=0&id=5 ...