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 ...
随机推荐
- C++模板的特化
C++类模板的三种特化,讲得比较全面 By SmartPtr(http://www.cppblog.com/SmartPtr/) 针对一个模板参数的类模板特化的几种类型, 一是特化为绝对类型(全特化) ...
- odoo中的ORM操作
ORM方法简介 OpenERP的关键组件, ORM是一个完整的对象关系映射层,是开发人员不必编写基本的SQL管道. 业务对象被声明继承字models.Models的python类. 这让业务对象在OR ...
- ASP.NET MVC和ASP.NET Core MVC中获取当前URL/Controller/Action (转载)
ASP.NET MVC 一.获取URL(ASP.NET通用): [1]获取完整url(协议名+域名+虚拟目录名+文件名+参数) string url=Request.Url.ToString(); [ ...
- (原创)odoo关系字段在视图中的行为控制 总结
字段类型 选项或属性 格式示例 描述 many2one , many2many_tags(widget) no_create options='{"no_create":True} ...
- WPF 模拟UI 键盘录入
原文:WPF 模拟UI 键盘录入 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/yangyisen0713/article/details/1835 ...
- 浅谈CDQ分治与偏序问题
初识CDQ分治 CDQ分治是一个好东西,一直听着dalao们说所以就去学了下. CDQ分治是我们处理各类问题的重要武器.它的优势在于可以顶替复杂的高级数据结构,而且常数比较小:缺点在于必须离线操作. ...
- tensorflow笔记:多层LSTM代码分析
tensorflow笔记:多层LSTM代码分析 标签(空格分隔): tensorflow笔记 tensorflow笔记系列: (一) tensorflow笔记:流程,概念和简单代码注释 (二) ten ...
- Part 6:静态文件--Django从入门到精通系列教程
该系列教程系个人原创,并完整发布在个人官网刘江的博客和教程 所有转载本文者,需在顶部显著位置注明原作者及www.liujiangblog.com官网地址. 前面我们编写了一个经过测试的投票应用,现在让 ...
- Azure Load Balancer : 简介
Azure 提供的负载均衡服务叫 Load Balancer,它工作在 ISO 七层模型的第四层,通过分析 IP 层及传输层(TCP/UDP)的流量实现基于 "IP + 端口" 的 ...
- 浅谈移动端设备标识码:DeviceID、IMEI、IDFA、UDID和UUID
---恢复内容开始--- 转:https://www.jianshu.com/p/38f4d1a4763b [心路历程] 最近刚好在思考工作中统计数据所用的标识码产生的数据误差到底有多大,借此机会几番 ...