BZOJ4120 : [Baltic2015]Editor

活跃区的操作序列的优先级单调不上升,所以每次undo的一定是一段区间。

以优先级为权值建立可持久化权值线段树,维护优先级在某区间内的最靠后的位置。

#include<cstdio>
const int N=300010,M=6000000;
int n,i,j,x,f[N],root[N],v[M],l[M],r[M],tot;
inline void read(int&a){
  char c;bool f=0;a=0;
  while(!((((c=getchar())>=‘0‘)&&(c<=‘9‘))||(c==‘-‘)));
  if(c!=‘-‘)a=c-‘0‘;else f=1;
  while(((c=getchar())>=‘0‘)&&(c<=‘9‘))(a*=10)+=c-‘0‘;
  if(f)a=-a;
}
inline int max(int a,int b){return a>b?a:b;}
int ins(int x,int a,int b,int c,int d){
  int y=++tot;v[y]=max(v[x],d);
  if(a==b)return y;
  int mid=(a+b)>>1;
  if(c<=mid)l[y]=ins(l[x],a,mid,c,d),r[y]=r[x];else l[y]=l[x],r[y]=ins(r[x],mid+1,b,c,d);
  return y;
}
int ask(int x,int a,int b,int c){
  if(!x)return 0;
  if(b<=c)return v[x];
  int mid=(a+b)>>1,t=ask(l[x],a,mid,c);
  if(c>mid)t=max(t,ask(r[x],mid+1,b,c));
  return t;
}
int main(){
  for(read(n),i=1;i<=n;printf("%d\n",f[i++])){
    read(x);
    if(x>0)f[i]=x,root[i]=ins(root[i-1],0,n,0,i);
    else f[i]=f[j=ask(root[i-1],0,n,-x-1)-1],root[i]=ins(root[j],0,n,-x,i);
  }
  return 0;
}

  

时间: 2024-08-25 10:20:34

BZOJ4120 : [Baltic2015]Editor的相关文章

安卓-SharedPreferences和Editor保存数据

SharedPreferences是Android中最容易理解的数据存储技术,实际上SharedPreferences处理的就是一个key-value(键值对)SharedPreferences常用来存储一些轻量级的数据. 在做连连看游戏的时候,需要保存游戏进度,所以稍微用了一下,这里做个小结. 我的做法是,首先给出如下定义: private SharedPreferences sp; private static String MY_APP="MYAPP"; 然后再写两个方法,执行数

(原创)EasyUI中datagrid的行编辑模式中,找到特定的Editor,并为其添加事件

有时候在行编辑的时候,一个编辑框的值要根据其它编辑框的值进行变化,那么可以通过在开启编辑时,找到特定的Editor,为其添加事件 // 绑定事件, index为当前编辑行 var editors = $('#staffLogDetailGrid').datagrid('getEditors', index);     //获得当前行的编辑对象 console.info(editors[5]);  //editor[5]表示第五列这个控件 var sfgzEditor = editors[5];

Unity报错 : BCE0004: Ambiguous reference &#39;preview&#39;: CameraMotionBlurEditor.preview, UnityEditor.Editor.preview.

建立项目版本为Unity4.6,改为5.3.4版本,运行项目报如下错误: "BCE0004: Ambiguous reference 'preview': CameraMotionBlurEditor.preview, UnityEditor.Editor.preview." 修改  preview 为 preview_ var preview_ : SerializedProperty; preview_ = serObj.FindProperty ("preview&qu

sitecore+score 在 Experience editor 添加新元素时associateed content 指向错误

Q:在sitecore的Experience editor页面添加component时,子元素的路径指向错误.如图: A: 首先你要整理思路,这个设置可能是在哪,是template还是control layout.当然这里肯定是跟页面control有关. 1.我们需要找到这个button的control layout.因为我们的项目是集成了score,所以根据score的手册我们知道这个button的路径在/sitecore/layout/Renderings/BootstrapUI/Conte

sitecore 非admin的用户在Experience editor页面不能显示no text in field

Q:在zh-cn语言下Experience editor 用户不能看到no text in field 提示文字,以至于用户很难定位到所要编辑内容的区域 A: 1.到sitecore后台,切换到core数据库下,找到/sitecore/content/Applications/WebEdit/WebEdit Texts这个节点. 2.切换到中文下,看当前节点是否有zh-cn版本,如果不存在就需要新建中文版本. 3.然后在default text里面填写no text in field,或者填写上

editor does not contain a main type的解决方案

editor does not contain a main type的解决方案 今天用eclipse,当打算run一个带有main函数的class时,出现editor does not contain a main type的错误框. baidu了一下,迅速解决问题:原来这个class所在包没有被添加到build path中. 解决方法:在左侧的package explorer中右击这个class所在包的上一级目录--build path--use as source folder.这样就解决

VS 2010使用Color Theme Editor插件

使用Visual Studio Color Theme Editor 改变VS 2010的主题色,也可以配置自己喜欢的颜色 工具/原料 Visual Studio 2010 Visual Studio Color Theme Editor 安装Visual Studio Color Theme Editor 安装该插件可以从网站下载安装,也可以从VS 2010里面安装.本经验选择从VS 2010的 Extension Manager中安装. 启动VS 2010,选择“Tools”-“Extens

Unity Editor Extensions – Menu Items

转载请注明出处:http://blog.csdn.net/u010019717 更全的内容请看我的游戏蛮牛地址:http://www.unitymanual.com/space-uid-18602.html Unity 编辑器允许添加自定义菜单的外观和行为类似内置菜单.这可以用于添加经常常用的功能,可直接从编辑器UI操作. 在这篇文章中,我将展示如何利用新的菜单menu items,Unity 编辑器中创建并尝试提供真实世界的例子用法,对于每个描述的topic. 添加菜单项 为了向top-lev

Unity Editor Extensions – Custom Inspectors

?? 转载请注明出处:http://blog.csdn.net/u010019717 更全的内容请看我的游戏蛮牛地址:http://www.unitymanual.com/space-uid-18602.html 这是在"Unity Editor Extension"系列的第 2 次帖子. post描述了为创建自定义inspectors面板在 Unity 编辑器的基本步骤.在该系列的下一个posts,我将深入探讨更高级的主题,例如inspectors及Unity's serializa