Div1 530

  • 感受到被Div1支配的恐惧了.jpg
  • 真·一个题都不会.jpg(虽然T1是我智障
  • 感受到被构造题支配的恐惧了.jpg

A

直接树上贪心就行,是我写错了.jpg

B

这个构造超级神仙有没有.jpg

给定的答案矩阵一定满足,每一行或者每一列只有两种不同的字符交替出现

然后枚举+贪心即可...

C

被老K Diss了.jpg

这题给人的第一印象就是一个非常智障的构造。

然后发现它还有要求...每个节点的度数最大值最小...

然后就不会了.jpg

(开什么玩笑,怎么可能不会!

然后就可以通过枚举这个最大值的方式解决,然后剩下的就直接连在某个点上来满足它的要求...

具体实现看代码吧...有点说不清

总之就是一个$K$叉树+一条链...

#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define ll long long
int fa[N],n,p;ll now,a[N];
int main()
{
scanf("%d%lld",&n,&now);
if(now*2>(ll)n*(n+1))return puts("No"),0;
if(now<n*2-1)return puts("No"),0;
for(p=1;p<=n;p++)
{
long long dep=1,cnt=1,t=1,c=1;
while(cnt<n)c=c*p,dep++,t+=dep*min(c,n-cnt),cnt+=c;
if(t<=now)break;
}
puts("Yes");
long long dep=1,cnt=1,t=1,c=1;a[1]=1;
while(cnt<n)
{
dep++;c=c*p;a[dep]=min(c,n-cnt);
t+=dep*min(c,n-cnt),cnt+=c;
}now-=t;
long long now_d=dep,aft_d=dep+1;
while(now)
{
if(a[now_d]<=1)now_d--;
a[now_d]--;ll tmp=min(aft_d++,now_d+now);
now-=tmp-now_d;a[tmp]++;
}
int lst=1;
for(int i=2;i<aft_d;i++)
{
int nowp=lst-a[i-1]+1,nowk=0;
// printf("%lld\n",a[i]);
for(int j=lst+1;j<=lst+a[i];j++)
{
if(nowk==p)nowp++,nowk=0;
nowk++,fa[j]=nowp;
}lst+=a[i];
}
for(int i=2;i<=n;i++)printf("%d ",fa[i]);puts("");
}
//sdadasdasd

D

这个读题杀啊...

根本读不懂啊.jpg

读懂了就是维护一个动态前缀和来求满足这个式子$sum_{i-1}\times 2\le a_i$的$i$的数量.jpg

那么显然,答案小于$30$

然后就直接树状数组+set即可...

每次找到$\min {a_i}$然后每次翻倍去找+树状数组查前缀和.jpg

就是慢了点.jpg

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
#include <set>
using namespace std;
#define N 500005
#define ll long long
int w[N],p[N],n,sp;char str[10];
multiset<int >s;int siz;ll c[N];
void fix(int x,int v){for(;x<=sp;x+=x&-x)c[x]+=v;}
ll find(int x){ll ret=0;for(;x;x-=x&-x)ret+=c[x];return ret;}
void add(int x){siz++;s.insert(p[x]);fix(x,p[x]);}
void del(int x){siz--;s.erase(s.find(p[-x]));fix(-x,-p[-x]);}
int get_ans()
{
if(!siz)return 0;
int ret=1,now=*s.begin();
while(1)
{
if(now>1e9)break;
if(s.upper_bound(now<<1)!=s.end())
{
int t=*s.upper_bound(now<<1);
t=lower_bound(p+1,p+sp+1,t)-p;
if(find(t-1)*2<p[t])ret++;now=p[t]+now;
}else return siz-ret;
}return siz-ret;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%s%d",str,&p[i]),(str[0]=='+'?(w[i]=p[i]):(w[i]=-p[i]));
sort(p+1,p+n+1);sp=unique(p+1,p+n+1)-p-1;
for(int i=1;i<=n;i++)w[i]=(w[i]<0)?-(lower_bound(p+1,p+sp+1,-w[i])-p):lower_bound(p+1,p+sp+1,w[i])-p;
for(int i=1;i<=n;i++)
if(w[i]<0)del(w[i]),printf("%d\n",get_ans());
else add(w[i]),printf("%d\n",get_ans());
}
// dasdasd

Codeforces round 1098的更多相关文章

  1. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  2. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  3. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  6. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  7. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

  8. Codeforces Round #370 - #379 (Div. 2)

    题意: 思路: Codeforces Round #370(Solved: 4 out of 5) A - Memory and Crow 题意:有一个序列,然后对每一个进行ai = bi - bi  ...

  9. Codeforces Round #371 (Div. 1)

    A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...

随机推荐

  1. 【读书笔记】iOS-照相机与摄像头

    一,增强现实 增强现实(AR)是一种实时地计算摄影机影像的位置及角度并加上相应图像的技术,这种技术的目标是在屏幕上把虚拟世界套在现实世界并进行互动.这种技术估计由1990年提出.随着随身电子产品运算能 ...

  2. ArcGIS JavaScript API动态图层

      矢量动态图层     <!DOCTYPE HTML> <html>   <head> <meta http-equiv="Content-Typ ...

  3. 在Salesforce中使用静态资源

    静态资源 静态资源是Salesforce中默认的一种数据类型,用户可以上传各种文件,比如zip文件.jpg文件.css文件.图像文件等. 在Visualforce页面.Lightning框架的开发过程 ...

  4. Python从入门到精通

    最近研究了一下Python,名不虚传,确实挺精彩. 学习一门新的语言,我认为从入门到精通的做法是:下SDK.装IDE.练教程.结合工作应用.不断踩坑进阶.梳理总结 1.下SDK(2.7.15) 下载地 ...

  5. Angular基础(四) 创建Angular应用

    应用(Application)是由组件构成的树.树的根部是最顶层的组件即应用本身,启动的时候,浏览器会最先渲染顶层组件,然后根据树形结构,迭代渲染子组件.组件是可装配的,可以互相组合以构成更大的组件. ...

  6. 泛化之美--C++11可变模版参数的妙用

    1概述 C++11的新特性--可变模版参数(variadic templates)是C++11新增的最强大的特性之一,它对参数进行了高度泛化,它能表示0到任意个数.任意类型的参数.相比C++98/03 ...

  7. Python 文档学习

    1.在命令行执行Python脚本(获取输入) import sys print(sys.argv[1]) 2.compile Python(编译Python) 编译后,生成的文件是.pyc,但是要知道 ...

  8. [20170728]oracle保留字.txt

    [20170728]oracle保留字.txt --//oracle有许多保留字,我印象最深的就是使用rman备份表空间test,test就是rman里面的保留字.--//还有rman也是rman里面 ...

  9. 洗礼灵魂,修炼python(42)--巩固篇—type内置函数与类的千丝万缕关系

    type函数的隐藏属性 相信大家都知道内置函数type是用来查看对象的数据类型的.例: 那比如我对int类查看类型呢? 有朋友会说,int是内置类啊,用自定义的应该不会这样,我们自定义一个类呢? 还是 ...

  10. sql server递归

    with cte as ( select belongsAgent from [QPProxyDB].[dbo].[BS_ProxyInfo] where ProxyID = @ProxyID uni ...