Codeforces round 1098
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的更多相关文章
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- 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 ...
- 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 ...
- Codeforces Round #370 - #379 (Div. 2)
题意: 思路: Codeforces Round #370(Solved: 4 out of 5) A - Memory and Crow 题意:有一个序列,然后对每一个进行ai = bi - bi ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
随机推荐
- php向数据库插入数据
<?php header("Content-type: text/html;charset=utf-8"); $con = mysql_connect("local ...
- spark (java API) 在Intellij IDEA中开发并运行
概述:Spark 程序开发,调试和运行,intellij idea开发Spark java程序. 分两部分,第一部分基于intellij idea开发Spark实例程序并在intellij IDEA中 ...
- Salesforce的基础用户界面定制
Salesforce的用户界面 Salesforce的用户界面易于定制.本文将讲述如何定制: 主菜单和选项卡 自定义按钮和链接 视图列表 页面布局 定制主菜单和选项卡 Salesforce的主菜单默认 ...
- cve-list
dlink CVE-2018-17786 CVE-2018-17787 CVE-2018-17880 CVE-2018-17881 mongoose CVE-2018-10945 openwrt CV ...
- plt 数据可视化
1.plt.plot(x,y,color) 折线坐标图 import matplotlib.pyplot as plt h = np.linspace(1, 10, 10) v = np.linspa ...
- il8n国际化
il8n国际化 支持多国语言的web应用,根据客户端系统的语言类型返回对应的界面 方案 为每种语言提供一套相应的资源文件,并以规范化命名的方式保存在特定的目录中,由系统自动根据客户端语言选择适合的资源 ...
- 洗礼灵魂,修炼python(59)--爬虫篇—httplib模块
httplib 1.简介 同样的,httplib默认存在于python2,python3不存在: httplib是python中http协议的客户端实现,可以用来与 HTTP 服务器进行交互,支持HT ...
- C#使用Aforge调用摄像头拍照
一. 新建一个Winform项目 二.使用Nuget添加引用 安装下图中红色框住的两个程序包 安装完后发现安装了如下图的程序包,这是因为上述两个程序包存在对其它程序包的依赖. 三.编写程序 1. 窗体 ...
- 【PAT】B1078 字符串压缩与解压(20 分)
主函数接收下第一个字符,接着一个分支就转到两个函数中的一个 1.压缩简单,只要与下一个一样就只计数,如果不同了就直接输出 2.至于解压不知道数字是几位数,所以我直接用了sscanf,然后判断是几位数字 ...
- node学习笔记_04 express相册
学习node用express框架做了一个相册展示及上传功能: 1.没有连接服务器,这里全部是操作文件夹 2.安装上传文件的依赖formidable,npm install --save formida ...