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. Android OpenMAX(三)高通OMX组件实现基础

    上一节了解了OMX组件实现的基础内容,这一节我们以高通OMX实现为例,简单看看如何实现一个OMX组件.本节代码参考自: omx_core_cmp.cpp qc_omx_component.h omx_ ...

  2. zfile 在线云盘、网盘、OneDrive、云存储、私有云、对象存储、h5ai、上传、下载

    基于 Java 的在线网盘程序,支持对接 S3.OneDrive.SharePoint.又拍云.本地存储.FTP.SFTP 等存储源,支持在线浏览图片.播放音视频,文本文件.Office.obj(3d ...

  3. 🐞vue兄弟组件中方法互相调用

    场景:父组件中同时引入两个子组件(A和B),此时B组件点击按钮需要调用A组件里面的方法 方案1:vue的事件总线 方案2:自定义事件($emit) 最终方案:方案2 父组件 具体操作 B组件上添加一个 ...

  4. LINQ to Entities does not recognize the method 'System.String ToString()' method

    LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method ca ...

  5. rest接口list参数接收

    list<String> post传参 ["1112","2222","3332"]list<Object> pos ...

  6. Java反射获取字段的属性值及对比两个对象的属性值null差异赋值,递归算法查找

    package com.example.demo; import java.lang.reflect.Field; /** * 需求描述:同一类的不同对象,如果某个字段的null则从另外的一个对象中赋 ...

  7. 以沙箱的方式运行容器:安全容器gvisor

    目录 一.系统环境 二.前言 三.安全容器隔离技术简介 四.Gvisor简介 五.容器runtime简介 六.docker容器缺陷 七.配置docker使用gVisor作为runtime 7.1 安装 ...

  8. Linux 内核:设备驱动模型(5)平台设备驱动

    Linux 内核:设备驱动模型(5)平台设备驱动 背景 我们已经大概熟悉了Linux Device Driver Model:知道了流程大概是怎么样的,为了加深对LDDM框架的理解,我们继续来看pla ...

  9. ZYNQ:使用PetaLinux打包 BOOT.BIN、image.ub

    说明 个人还是比较喜欢灵活去管理各个部分的源码. 有关文章: ZYNQ:PetaLinux提取Linux和UBoot配置.源码 编译Linux 取得Linux源代码和配置后,可以在其中执行make,编 ...

  10. 【Kafka最佳实践】合理安排kafka的broker、partition、consumer数量

    broker的数量最好大于等于partition数量 一个partition最好对应一个硬盘,这样能最大限度发挥顺序写的优势. 一个broker如果对应多个partition,需要随机分发,顺序IO会 ...