1. 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; }
}
}
  1. 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)的更多相关文章

  1. 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 ...

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

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

  3. Codeforces Round #368 (Div. 2)

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

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

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

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

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

  6. 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 ...

  7. 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 ...

  8. Codeforces Round #371 (Div. 1)

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

  9. Codeforces Round #268 (Div. 2) ABCD

    CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...

  10. 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts

    题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...

随机推荐

  1. Bear and String Distance

    传送锚点: codeforces.com Copy 4 26 bear output roar input 2 7 af output db input 3 1000 hey output -1 思路 ...

  2. weak引用表原理探究

    一.weak引用实现原理探究 首先对<Xcode 10 下如何调试objc4-723>建立的objc源码调试工程表示感谢! 地址:https://www.jianshu.com/p/9e0 ...

  3. 电脑网卡把报文的vlan tag去掉

    1 现象 现象说明:从电脑的网卡(用的Realtek)进来一个带vlan tag的报文,但是使用wireshark抓取的报文没有vlan tag. 解决方式如下:需要注册表. 参考链接1:https: ...

  4. 鸿蒙HarmonyOS实战-ArkTS语言基础类库(XML)

    前言 数据传输的数据格式有以下几种常见的格式: JSON(JavaScript Object Notation):JSON是一种轻量级的数据交换格式,可读性高且易于解析.它使用键值对的方式表示数据,并 ...

  5. 连续段 dp - 状态转移时依赖相邻元素的序列计数问题

    引入 在一类序列计数问题中,状态转移的过程可能与相邻的已插入元素的具体信息相关. 这类问题通常的特点是,如果只考虑在序列的一侧插入,问题将容易解决. 枚举插入顺序的复杂度通常难以接受,转移时枚举插入位 ...

  6. Go版RuoYi

    RuoYi-Go  https://github.com/Kun-GitHub/RuoYi-Go 1. 关于我 个人介绍 2. 介绍 后端用Go写的RuoYi权限管理系统 (功能正在持续实现)后端 G ...

  7. Mysql联合索引生效、失效条件

    引言 联合索引又叫复合索引.两个或更多个列上的索引被称作复合索引. 对于复合索引:Mysql从左到右的使用索引中的字段,一个查询可以只使用索引中的一部份,但只能是最左侧部分.例如索引是key inde ...

  8. 支付宝spi接口设计验签和返回结果加签注意点,支付宝使用JSONObject对象

    支付宝spi接口设计验签和返回结果加签注意点,支付宝使用JSONObject对象 SPI 三方服务接入指南https://opendocs.alipay.com/isv/spiforisv 服务端实现 ...

  9. window10 java环境变量配置

    window10 此电脑 右击属性 相关设置 高级系统配置 点击右下的 环境变量 在系统变量中新增JAVA_HOME=D:\Program Files\Java\jdk1.8.0_25 在系统变量中修 ...

  10. linux elasticsearch-8.2.0安装

    1.下载,解压缩,命令行前不要留空格 官网下载地址: https://www.elastic.co/cn/downloads/elasticsearch https://artifacts.elast ...