Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) A,B,C
A.题目链接:http://codeforces.com/contest/828/problem/A
解题思路:
直接暴力模拟
#include<bits/stdc++.h>
using namespace std; int main()
{
int m,d,s,i,num=,ans=,a[];
cin>>m>>d>>s;
for(i=;i<m;i++){
cin>>a[i];
if(a[i]==&&d)
d--;
else if(a[i]==&&d==&&s){
s--;num++;
}
else if(a[i]==&&s){
s--;
}
else if(a[i]==&&s==)
ans+=;
else if(a[i]==&&s==&&d==&&num)
num--;
else if(a[i]==&&s==&&d==&&num==)
ans++;
}
cout<<ans<<endl;
}
B.题目链接:http://codeforces.com/contest/828/problem/B
思路:
暴力
#include<bits/stdc++.h>
using namespace std;
#define inf 2e9
int main()
{
char mp[][];
int m,n,i,j,num=,ans=;
cin>>m>>n;
for(i=;i<=m;i++){
for(j=;j<=n;j++){
cin>>mp[i][j];
}
}
int maxi = -inf,maxj = -inf;
int mini = inf,minj=inf;
for(i=;i<=m;i++){
for(j=;j<=n;j++){
if(mp[i][j]=='B'){
if(i>maxi)
maxi = i;
if(i<mini)
mini = i;
if(j>maxj)
maxj = j;
if(j<minj)
minj = j;
num+=;
}
}
}
if(num==){
cout<<""<<endl;
return ;}
//cout<<num<<endl;
ans = max((maxi-mini+),(maxj - minj+));
//cout<<ans<<endl;
if(ans>m||ans>n)
cout<<"-1"<<endl;
else{
cout<<ans*ans-num<<endl;
}
return ;
}
C.题目链接:http://codeforces.com/contest/828/problem/C
解题思路:
暴力会超时,he前一区域比较,如果没有重合的进行替换操作,重合跳过;
#include<bits/stdc++.h>
using namespace std;
char s[];
int main()
{
int m,n,i,j,k,pre,x,maxx = -;
string s1;
ios::sync_with_stdio(false);
cin.tie();
cin>>m;
memset(s,'a',sizeof(s));
while(m--){
cin>>s1>>n;
int len = s1.size();
pre = -len;
for(i=;i<n;i++){
cin>>x;
for(k=max(,len-(x-pre));k<len;++k){
s[x+k-] = s1[k];
pre = x;
}
maxx = max(maxx,x+len-);
}
}
for(i=;i<maxx;i++)
cout<<s[i];
cout<<endl;
return ;
}
Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) A,B,C的更多相关文章
- Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals)
Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals) A.String Reconstruction B. High Load C ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) E. DNA Evolution 树状数组
E. DNA Evolution 题目连接: http://codeforces.com/contest/828/problem/E Description Everyone knows that D ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) Problem E (Codeforces 828E) - 分块
Everyone knows that DNA strands consist of nucleotides. There are four types of nucleotides: "A ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) D. High Load 构造
D. High Load 题目连接: http://codeforces.com/contest/828/problem/D Description Arkady needs your help ag ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) C. String Reconstruction 并查集
C. String Reconstruction 题目连接: http://codeforces.com/contest/828/problem/C Description Ivan had stri ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 828D) - 贪心
Arkady needs your help again! This time he decided to build his own high-speed Internet exchange poi ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) Problem C (Codeforces 828C) - 链表 - 并查集
Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) Problem A - B
Pronlem A In a small restaurant there are a tables for one person and b tables for two persons. It i ...
- Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals)
题目链接:http://codeforces.com/contest/828 A. Restaurant Tables time limit per test 1 second memory limi ...
随机推荐
- SQL Server中的Merge关键字(转载)
简介 Merge关键字是一个神奇的DML关键字.它在SQL Server 2008被引入,它能将Insert,Update,Delete简单的并为一句.MSDN对于Merge的解释非常的短小精悍:”根 ...
- React + js-xlsx构建Excel文件上传预览功能
首先要准备react开发环境以及js-xlsx插件 1. 此处省略安装react安装步骤 2.下载js-xlsx插件 yarn add xlsx 或者 npm install xlsx 在项目中引入 ...
- Luogu P3177 [HAOI2015]树上染色
一道有机结合了计数和贪心这一DP两大考点的神仙题,不得不说做法是很玄妙. 首先我们很容易想到DP,设\(f_{i,j}\)表示在以\(i\)为根节点的子树中选\(j\)个黑色节点的最大收益值. 然后我 ...
- C#断点续传下载。
断点续传 最近在优化之前的下载流程,仅此篇幅留作笔记之用,日后其他研究此类问题的伙伴可以马上了解原理和开发,减少开发成本. 原理:断点续传目前比较通用的是使用HTTP续传方式,相关的资料可以通过访问: ...
- 计算机网络什么是OSI7层模型、TCP/IP4层模型理解
模型图解 应用层 就是最顶层的.通常指的应用程序初始走的协议比如有 TFTP,HTTP,SNMP,FTP,SMTP,DNS,Telnet 表示层 主要对数据应用层的数据包进行加密 会话层 建立.管理. ...
- Haproxy基础知识 -运维小结
开源软件负载均衡器 现在常用的三大开源软件负载均衡器分别是Nginx.LVS.Haproxy. 在之前的文章中已经对比了这三个负载均衡软件, 下面根据自己的理解和使用经验, 再简单说下这三个负载均衡软 ...
- Zookeeper Ephemeral结点使用心得
原文地址:https://www.cnblogs.com/linlemo/p/4807178.html 公司里面在拿Zookeeper做命名服务,通过使用ZK,前端只需要根据指定的ZK地址获得相应的资 ...
- 作用域&作用域链和with,catch语句&闭包
作用域(函数) 作用域:变量与函数的可访问范围,即作用域控制着变量与函数的可见性和生命周期; 在一些类C编程语言中花括号内的每一段代码都有各自的作用域,而且变量在声明它们的代码段外是不可见的,称之为块 ...
- 自己搭建的一个react脚手架
包括了: react.react router(v4), webpack(v4),echarts, google的组件库material ui, 后期会加上redux但是这些做中小型系统已经够了,de ...
- 注解Annotation
@java.lang.annotation.Target(value={java.lang.annotation.ElementType.TYPE}) @java.lang.annotation.Re ...