这一次又崩了,最后只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. matplotlib的一些代码

    Matplotlib Python 画图教程 (莫烦Python)_演讲•公开课_科技_bilibili_哔哩哔哩 https://www.bilibili.com/video/av16378354/ ...

  2. 数据库连接池libzdb

    官网:http://www.tildeslash.com/libzdb/ A small, easy to use Open Source Database Connection Pool Libra ...

  3. 数据库(11)-- Hash索引和BTree索引 的区别

    索引是帮助mysql获取数据的数据结构.最常见的索引是Btree索引和Hash索引. 不同的引擎对于索引有不同的支持:Innodb和MyISAM默认的索引是Btree索引:而Mermory默认的索引是 ...

  4. vue生命周期探究(二)

    vue生命周期探究(二) 转载自:https://segmentfault.com/a/1190000008923105 上一章我们介绍了vue的组件生命周期和路由勾子,这一章,让我们来看看在vue- ...

  5. yii2使用 db log

    在本地测试的时候,输出log,还是输出到db中比较顺手. 配置过程: 1.加入log组件的配置: 'log' =>[ # 追踪级别 # 消息跟踪级别 # 在开发的时候,通常希望看到每个日志消息来 ...

  6. 《阿里巴巴Java开发规约》插件使用

    通过Jetbrains官方仓库安装 1. 打开 Settings >> Plugins >> Browse repositories... 2. 在搜索框输入alibaba即可 ...

  7. iframe的应用量还是这么大

    以前查阅资料说iframe已经过时,不建议使用,可是在先进的2018年,你去随便打开一个网站,扔都可以见到iframe的身影,这不禁要发问:iframe的应用量为什么还是这么大? HTML5不再支持使 ...

  8. 20135302魏静静——linux课程第三周实验及总结

    linux课程第三周实验及总结 一.实验:跟踪分析Linux内核的启动过程 使用gdb跟踪调试内核从start_kernel到init进程启动 使用实验楼的虚拟机打开shell cd LinuxKer ...

  9. linux启动过程⭐

    启动第一步--加载BIOS当你打开计算机电源,计算机会首先加载BIOS信息,BIOS信息是如此的重要,以至于计算机必须在最开始就找到它.这是因为BIOS中包含了CPU的相关信息.设备启动顺序信息.硬盘 ...

  10. php 与 c++ openssl 加密通信

    $key = '1234567890123456'; $iv = '1234567890123456'; $enc = openssl_encrypt("hello wolrd!" ...