SUM_ACM-Codeforces Round 941 (Div. 2)
- A
Card Exchange
https://codeforces.com/contest/1966/problem/A
思路:找规律,如果b>a,输出a,如果a中有大于等于b个数,输出b-1即可,如果a中小于b个数输出a。
点击查看代码
#include <bits/stdc++.h>
using namespace std;
int v[101];
int main (){
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int n;
cin>>n;
while(n--){
memset(v,0,sizeof v);
int res=0;
int a,b;
cin>>a>>b;
for(int i=1;i<=a;i++){
int c;
cin>>c;
v[c]++;
res=max(res,v[c]);
}
if(a<b){
cout<<a<<endl;
}else
{
if(res<b)
cout<<a<<endl;
else
cout<<b-1<<endl;
}
}
}
- B
Rectangle Filling
https://codeforces.com/contest/1966/problem/B
思路:找出不可能的条件为:最上层和最下层不同输出为NO(这里最上层和最下层中的所有元素相同)。
代码如下:
点击查看代码
#include <bits/stdc++.h>
using namespace std;
char mp[502][502];
int main (){
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int n;
cin>>n;
while(n--){
memset(mp,0,sizeof mp);
int pd1=0;
int pd11=0;
int pd00=0;
int pd0=0;
int pd33=0;
int pd3=0;
int pd4=0;
int pd44=0;
int a,b;
cin>>a>>b;
for(int i=1;i<=a;i++){
for(int j=1;j<=b;j++){
cin>>mp[i][j];
}
}
for(int j=1;j<=b;j++)
{
if(mp[1][j]=='B')
pd0++;
}
for(int j=1;j<=b;j++)
{
if(mp[1][j]=='W')
pd1++;
}
for(int j=1;j<=b;j++)
{
if(mp[a][j]=='B')
pd00++;
}
for(int j=1;j<=b;j++)
{
if(mp[a][j]=='W')
pd11++;
}
for(int j=1;j<=a;j++)
{
if(mp[j][1]=='B')
pd3++;
}
for(int j=1;j<=a;j++)
{
if(mp[j][1]=='W')
pd4++;
}
for(int j=1;j<=a;j++)
{
if(mp[j][b]=='B')
pd33++;
}
for(int j=1;j<=a;j++)
{
if(mp[j][b]=='W')
pd44++;
}
if((pd1==b&&pd00==b)||(pd0==b&&pd11==b)||(pd3==a&&pd44==a)||(pd4==a&&pd33==a))
cout<<"NO"<<endl;
else
cout<<"YES"<<endl;
}
}
SUM_ACM-Codeforces Round 941 (Div. 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- 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 ...
- 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 ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
- 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...
随机推荐
- 基于 ESP8266_RTOS_SDK 驱动 DHT11
概述 DHT11模块使用一根data线实现信号触发以及数据反馈,信号格式参考如下 https://zhuanlan.zhihu.com/p/347904660 本文使用GPIO中断的方式采集反馈数据 ...
- objectarx 天正的墙转梁线
黄色的线是天正建筑2014画出来的墙炸开后的样子,炸开后全是AcDbLine.可以看到这个黄色的线在拐弯处,交叉处会出现多余的小线段,并且是不连续的,或者是超出了缺口,想要把它转变成梁就需要考虑这些因 ...
- Vue渲染函数与JSX指南
title: Vue渲染函数与JSX指南 date: 2024/6/3 下午6:43:53 updated: 2024/6/3 下午6:43:53 categories: 前端开发 tags: Vue ...
- python-一种去掉前后缀获取子串的方法
假设有一个字符串,其数据组成方式为:"mode_id1_str_id2",其中id1和id2为任意个数的数字,若存在mode,则id1必然也存在,否则都不存在:id2可有可没有. ...
- item2 报错 a session ended very soon after starting. check that the command in profile default
周末修改了阿里云 ecs 实例密码,再次用item2 远程连接服务器时,报一下的错误: 原因 每次使用ssh 远程新的连接,都会在 ~/.ssh/known_hosts 文件上生成 ssh 秘钥对,更 ...
- webpack代码分割
在做一些单页应用中,若不做任何处理,所有项目文件会打包为一个文件,这个文件非常的大,造成网页在首次进入时比较缓慢.做了代码分割后,会将代码分离到不同的chunk中,然后进行按需加载这些文件,能够提高页 ...
- Spring Data JPA 学习笔记1 - JPA与Spring Data
标记[跳过]的未来完善 1 理解JPA 1.1 什么是持久化? 当一个软件关闭的时候,软件内储存的状态数据还能在下次开启时被恢复,这就是持久化.对象持久化是指每个独立的对象的生命周期都能不依赖应用程序 ...
- R-tree算法
R-tree是一种用于处理空间数据的自平衡搜索树结构,特别适合于存储和查询二维或更高维度的空间对象,如点.线段.矩形等.它在地理信息系统.计算机图形学.数据库等领域有广泛应用.R树通过将空间分割成几个 ...
- 基于 Swagger 增强 UI FytApi.MUI
FytApi.MUI 介绍 基于swagger的轻量级,注入化的api-ui组件 支持netcore 3.1/5.0/6.0 特点 零浸入.轻量.简单.好看.好用 可配置权限认证以及Header,支持 ...
- 订单号规则,不能重复。redis去重 redis集合set应用
订单号规则,不能重复.redis去重 redis集合set应用 redis锁定商品解决并发售卖问题 RedisUtil工具类https://www.cnblogs.com/oktokeep/p/179 ...