这一次又崩了,最后只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. Go实现查找目录下(包括子目录)替换文件内容

    [功能] 按指定的目录查找出文件,如果有子目录,子目录也将进行搜索,将其中的文件内容进行替换. [缺陷] 1. 没有过滤出文本文件 2. 当文件过大时,效率不高 [代码] package main i ...

  2. 20165324《Java程序设计》第七周

    20165324<Java程序设计>第七周 教材学习内容总结 第11章 JDBC与MySOLz数据库 MySQL数据库管理系统,简称MySQL. 使用步骤: 启动MySQL数据库服务 器建 ...

  3. PEP8编码规范

    1.代码布局设计 1.1 缩进 -4个空格进行缩进 1.2 tab键-在python2中tab和空格是混用的,但是在python中基本上使用tab(pycharm开发工具会自动对代码缩进) 1.3 最 ...

  4. vertical-align和line-height的深入应用

    vertical-align和line-height的深入应用 本文的重点是了解vertical-align和line-height的使用 涉及到的名词:基线,底端,行内框,行框,行间距,替换元素及非 ...

  5. property函数的使用

    描述 property函数的作用是在新式类中返回属性值 在绑定属性时,如果我们直接把属性暴露出去,虽然写起来很简单,但是,没办法检查参数,导致可以把成绩随便改 s=Student() s.score= ...

  6. SQL Server语句创建数据库和表——并设置主外键关系

    简单的创建数据库的 SQL 语句: use master go if exists(select * from sysdatabases where name='Test') begin select ...

  7. C++ char float int string 之间的转换

    string str = "123"; string 转 int int i = atoi( str.c_str() ); string 转 float float f = ato ...

  8. 由浅入深之Tensorflow(4)----Saver&restore

    x = tf.placeholder(tf.float32) y = tf.placeholder(tf.float32) w = tf.Variable(tf.zeros([1, 1], dtype ...

  9. Java Calendar类总结

    在实际项目当中,我们经常会涉及到对时间的处理,例如登陆网站,我们会看到网站首页显示XXX,欢迎您!今天是XXXX年....某些网站会记录下用户登陆的时间,比如银行的一些网站,对于这些经常需要处理的问题 ...

  10. 在安装好MySql后忘记root的密码,或者给root添加密码

    一.编辑MySql的配置文件:my.ini(在MySql安装目录下). 打开配置文件,在文件最后一行添加:skip-grant-tables,然后保存退出. 意思为就是在启mysql时不启动grant ...