这一次又崩了,最后只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. 我在Xcode 6上Swift框架的测试经验分享

    我耗费了两个多月时间来琢磨Swift作为一门函数是编程语言都能做些什么,而今已经转移 到使用Swift来开发库文件了. 我花了一天的时间,最后发觉之前做的Swift特性探究是相当愉快的经历,我发现仍旧 ...

  2. Spring的AOP实现

    内容详见切面编程系列 https://www.cnblogs.com/jiyukai/category/1265045.html.

  3. Oracle trigger 触发器

    触发器使用教程和命名规范 目  录触发器使用教程和命名规范 11,触发器简介 12,触发器示例 23,触发器语法和功能 34,例一:行级触发器之一 45,例二:行级触发器之二 46,例三:INSTEA ...

  4. 我的Linux病毒追踪记录

    第一次自己一个人全权负责做游戏服务器,对于Linux安全并不太懂,所以就在昨天,服务器遭到了攻击,刚开始,只是发现服务器的带宽占满了,以为是带宽不够用,可是想想,弱联网游戏对带宽占用也不高啊而且带宽加 ...

  5. WordPress文章自动提取tag并添加链接

    我们在编写文章时,经常需要添加一些标签关键词的链接,这样不仅可以优化我们的内链,对用户来说也可以参照相关的文章,如果对文章的关键字进行手动添加链接,那样对我们来说太麻烦了,而且在标签关键词很多的情况下 ...

  6. Django框架_URLconf、Views、template、ORM

    目录: 一.Django-MTV MTV模型 Django基本命令 视图层之路由配置系统(views) 视图层之视图函数(views) 模板层(template) 二.Django-model基础 O ...

  7. Centos 6.5 Install Mysql 8.0.0

    依赖包 yum install numactl libaio perl-Time-HiRes per-devel -y 下载对应系统版本下载 wget http://cdn.mysql.com//Do ...

  8. 2016-2017 National Taiwan University World Final Team Selection Contest A - Hacker Cups and Balls

    题目: Dreamoon likes algorithm competitions very much. But when he feels crazy because he cannot figur ...

  9. TOSCA自动化测试工具--new Project

    1.在默认页面点击Project 进入new project页面 2.第一步出来的页面上点击new 3. 第2步弹出的页面上选择路径,project 名 3.OK之后就创建好了

  10. Spring事务回滚

    配置事物: @Configuration /**强制使用cglib代理时就把proxy-target-class设为true.*/ @EnableTransactionManagement(proxy ...