这一次又崩了,最后只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的更多相关文章

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

  2. Codeforces Round #423 (Div. 2)

    codeforces 423 A. Restaurant Tables [水题] //注意,一个人选座位的顺序,先去单人桌,没有则去空的双人桌,再没有则去有一个人坐着的双人桌.读清题意. #inclu ...

  3. Codeforces Round #423 B. Black Square

    题目网址:http://codeforces.com/contest/828/problem/B 题目: Polycarp has a checkered sheet of paper of size ...

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

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

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

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

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

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

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

随机推荐

  1. 转Hibernate 一对多关联的CRUD__@ManyToOne(cascade=(CascadeType.ALL))

    一:Group和Users两个类 假定一个组里有n多用户,但是一个用户只对应一个用户组. 1.所以Group对于Users是“一对多”的关联关系@OneToMany Users对于Group是“多对一 ...

  2. SDUT3145:Integer division 1(换零钱背包)

    题目:传送门 题目描述 整数划分是一个非常经典的数学问题. 所谓整数划分,是指把一个正整数n写成为n=m1+m2+...+mi的形式,其中mi为正整数,并且1<=mi<=n,此时,{m1, ...

  3. 多个JS文件性能优化

    页面中引入的JS文件是阻塞式加载的,这样会影响页面性能.以下是JS文件性能优化方法: 一:将所有的<script>标签放到页面底部,也就是</body>闭合标签之前,这能确保在 ...

  4. 避免SSH连接因超时闲置断开

    用SSH过程连接电脑时,经常遇到长时间不操作而被服务器踢出的情况,常见的提示如: Write failed: Broken pipe 这是因为如果有一段时间在SSH连接上无数据传输,连接就会断开.解决 ...

  5. pc端弹框

    pc弹框插件:http://aui.github.io/artDialog/doc/index.html#quickref-bubble PC端,手机端,layui很好用,分页啥的:http://ww ...

  6. bin2lib shell脚本

    #!/bin/sh#输入文件名filename=$1#分割文件大小filesize=4096#输出库文件名libname="lib"$(echo $filename | tr . ...

  7. POJ - 1966 Cable TV Network (最大流求点连通度)

    题意:求一个无向图的点连通度.点联通度是指,一张图最少删掉几个点使该图不连通:若本身是非连通图,则点连通度为0. 分析:无向图的点连通度可以转化为最大流解决.方法是:1.任意选择一个点作为源点:2.枚 ...

  8. 三张图看遍Linux性能监控、测试、优化工具

    Linux 平台上的性能工具有很多,眼花缭乱,长期的摸索和经验发现最好用的还是那些久经考验的.简单的小工具.系统性能专家 Brendan D. Gregg在最近的 LinuxCon NA 2014 大 ...

  9. win10+eclipse+hadoop2.7.2+maven+local模式直接通过Run as Java Application运行wordcount

    一.准备工作 (1)Hadoop2.7.2 在linux部署完毕,成功启动dfs和yarn,通过jps查看,进程都存在 (2)安装maven 二.最终效果 在windows系统中,直接通过Run as ...

  10. linux中uptime命令获取主机运行时间和查询系统负载信息

    系统中的uptime命令主要用于获取主机运行时间和查询linux系统负载等信息.uptime命令可以显示系统已经运行了多长时间,信息显示依次为:现在时间.系统已经运行了多长时间.目前有多少登陆用户.系 ...