Codeforces Round #423
这一次又崩了,最后只a了一题(还是被hack后才发现的错误)
第一题水题,多用一个数保存2-1后的数,注意先用2的桌子,再用这个
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 10007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f3f; int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n,a,b,c=;
cin>>n>>a>>b;
ll ans=;
for(int i=;i<n;i++)
{
int s;
cin>>s;
if(s==)
{
if(a>)a--;
else if(b>)c++,b--;
else if(c>)c--;
else ans++;
}
else
{
if(b>)b--;
else ans+=;
}
}
cout<<ans<<endl;
return ;
}
A
第二题,找最小的能覆盖所有B的正方形,输出最小不是B的值,暴力搜索比较一边,m写成n导致蹦了
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f3f; char ma[N][N];
bool vis[N][N];
int n,m;
bool ok()
{
for(int k=;k<=n;k++)
{
for(int l=;l<=n;l++)
{
if(!vis[k][l]&&ma[k][l]=='B')
return ;
}
}
return ;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie();
cin>>n>>m;
int l=,r=-,u=,d=-;
bool f=;
for(int i=;i<=n;i++)
{
for(int j=;j<=m;j++)
{
cin>>ma[i][j];
if(ma[i][j]=='B')
{
f=;
l=min(l,j);
r=max(r,j);
u=min(u,i);
d=max(d,i);
}
}
}
if(!f)
{
cout<<<<endl;
return ;
}
int p=max(r-l,d-u),ans=;
// cout<<p<<endl;
for(int i=;i+p<=n;i++)
{
for(int j=;j+p<=m;j++)
{
int te=;
memset(vis,,sizeof vis);
for(int k=i;k<=i+p;k++)
{
for(int l=j;l<=j+p;l++)
{
if(ma[k][l]!='B')
te++;
vis[k][l]=;
}
}
if(ok())ans=min(ans,te);
}
}
if(ans==)cout<<-<<endl;
else cout<<ans<<endl;
return ;
}
B
第三题字符串模拟,先标记,输出的时候判断谁的到达距离更远来决定要不要更新,还有数组记得开1e7
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f3f; string s[N];
int bj[N*];
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n,k;
cin>>n;
memset(bj,-,sizeof bj);
int maxx=;
for(int i=;i<n;i++)
{
cin>>s[i]>>k;
while(k--){
int a;
cin>>a;
int p=a+s[i].size();
maxx=max(maxx,p-);
if(bj[a]==-)bj[a]=i;
else
{
if(s[bj[a]].size()<s[i].size())
bj[a]=i;
}
}
}
for(int i=;i<=maxx;)
{
if(bj[i]==-)i++,cout<<'a';
else
{
int p=bj[i],te=s[p].size();
for(int j=;j<s[p].size();j++)
{
if(j!=&&bj[i+j]!=-&&s[bj[i+j]].size()>s[p].size()-j)
{
te=j;
break;
}
}
// cout<<te<<endl;
cout<<s[p].substr(,te);
i+=te;
}
}
cout<<endl;
return ;
}
C
第四题连通图,通过找规律可以发现,把1当作定点,第二层有k个点与1相连,然后依次链接到上一层,这样一定是有k个点为出口点
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f3f; vector<pair<int,int> >v;
int le[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n,k;
cin>>n>>k;
for(int i=;i<=k+;i++)
{
v.push_back(make_pair(,i));
le[i]=;
}
int t=k+,ans=;
while(t<=n){
v.push_back(make_pair(t-k,t));
le[t]=ans;
if((t-k-)%k==)ans++;
t++;
}
sort(le+,le++n);
cout<<le[n]+le[n-]-<<endl;
for(int i=;i<v.size();i++)
cout<<v[i].first<<" "<<v[i].second<<endl;
return ;
}
D
Codeforces Round #423的更多相关文章
- 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)
codeforces 423 A. Restaurant Tables [水题] //注意,一个人选座位的顺序,先去单人桌,没有则去空的双人桌,再没有则去有一个人坐着的双人桌.读清题意. #inclu ...
- Codeforces Round #423 B. Black Square
题目网址:http://codeforces.com/contest/828/problem/B 题目: Polycarp has a checkered sheet of paper of size ...
- 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) 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) A,B,C
A.题目链接:http://codeforces.com/contest/828/problem/A 解题思路: 直接暴力模拟 #include<bits/stdc++.h> using ...
- 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) 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 ...
随机推荐
- 1141 PAT Ranking of Institutions[难]
1141 PAT Ranking of Institutions (25 分) After each PAT, the PAT Center will announce the ranking of ...
- matlab 保存图片的几种方式
最近在写毕业论文, 需要保存一些高分辨率的图片. 下面介绍几种MATLAB保存图片的 方式. 一. 直接使用MATLAB的保存按键来保存成各种格式的图片 你可以选择保存成各种格式的图片, 实际上对于 ...
- UVALive - 4671 K-neighbor substrings (FFT+哈希)
题意:海明距离的定义:两个相同长度的字符串中不同的字符数.现给出母串A和模式串B,求A中有多少与B海明距离<=k的不同子串 分析:将字符a视作1,b视作0.则A与B中都是a的位置乘积是1.现将B ...
- Windows资源监控神器——perfmon
一.简述 笔者在用lr中control监控Windows资源的时候,有时候总是遇到卡死和报错,所以就发现了Windows自带的监控神器————perfmon. Perfmon提供了图表化的系统性能实时 ...
- 测试应用documentFragment 和 直接操作dom 的区别
DocumentFragment 节点不属于文档树,继承的 parentNode 属性总是 null. 不过它有一种特殊的行为,该行为使得它非常有用,即当请求把一个 DocumentFragment ...
- Ubuntu16.04中用et对jmeter生成的数据统计成图表
在Ubuntu系统中,用ctrl+Alt+t 打开终端: 输入et,即打开wps: 整理需要形成图表的数据,如: 用excel生成图表,如下: 表得出的性能图表,方法: 1.工具栏中选择插入——二维折 ...
- 微服务-使用Redis实现分布式缓存
在单体中对于key信息和用户信息是放在内存中放的,通过session进行管理. 微服务是要放在分布式缓存中,以实现服务的无状态化. @Autowired private StringRedisTemp ...
- java中boolean类型占几个字节
java的基本数据类型中,boolean只有两种状态,默认值为false.取值范围是{true,false},理论上占1bit,实际上: 1.单个的boolean 类型变量在编译的时候是使用的int ...
- CSS Outline(轮廓)
CSS Outline(轮廓) 一.CSS 轮廓(outline) 轮廓(outline)是绘制于元素周围的一条线,位于边框边缘的外围,可起到突出元素的作用. CSS outline 属性规定元素轮廓 ...
- [Linux 005]——IO重定向
通常在 Shell 中执行命令的时候,我们会在输入命令的下方看到执行结果,操作系统默认将命令的执行结果输出到显示器上.当然,我们也可以手动的指定输出路径,或者输入路径,这就是 I/O 重定向. 1.标 ...