传送门

解题思路

记得当时考试我还是个孩子,啥也不会QAQ。现在回头写,用动态开点的线段树,在每行和最后一列开线段树,然后对于每次询问,把x行y列的删去,然后再把x行m列的元素加入x行这个线段树,然后再把删去元素加到最后一列里,用一个vector维护变化后的标号。

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<vector> using namespace std;
const int MAXN = ;
typedef long long LL; inline int rd(){
int x=,f=;char ch=getchar();
while(!isdigit(ch)) {f=ch=='-'?:;ch=getchar();}
while(isdigit(ch)) {x=(x<<)+(x<<)+ch-'';ch=getchar();}
return f?x:-x;
} vector<LL> g[MAXN];
int n,m,q,Max,num,rt[MAXN];
LL pos;
int sum[MAXN<<],ls[MAXN<<],rs[MAXN<<]; LL query(int x,int l,int r,int k){
if(l==r) return l;
int mid=l+r>>,sizl=mid-l+-sum[ls[x]];
if(sizl>=k) return query(ls[x],l,mid,k);
else return query(rs[x],mid+,r,k-sizl);
} void modify(int &x,int l,int r){
if(!x){
x=++num;
ls[x]=rs[x]=;
}
sum[x]++;
if(l<r){
int mid=l+r>>;
if(mid>=pos) modify(ls[x],l,mid);
else modify(rs[x],mid+,r);
}
} LL Del_r(int x,LL now){
pos=query(rt[n+],,Max,x);
modify(rt[n+],,Max);
LL ret=pos<=n?1ll*pos*m:g[n+][pos-n-];
g[n+].push_back(now?now:ret);
return ret;
} LL Del_l(int x,int y){
pos=query(rt[x],,Max,y);modify(rt[x],,Max);
LL ret=pos<m?1ll*(x-)*m+pos:g[x][pos-m];
g[x].push_back(Del_r(x,ret));
return ret;
} int main(){
n=rd(),m=rd(),q=rd();Max=max(n,m)+q;
int x,y;
while(q--){
x=rd(),y=rd();
if(y==m) printf("%lld\n",Del_r(x,));
else printf("%lld\n",Del_l(x,y));
}
return ;
}

最新文章

  1. .Net语言 APP开发平台——Smobiler学习日志:Poplist控件的正确打开方式以及如何快速实现
  2. 如何判断exe或dll的目标平台及是否是.NET?
  3. CSS--结构和层叠
  4. 802.11协议帧格式、Wi-Fi连接交互过程、无线破解入门研究
  5. loadrunner中定义数组
  6. 关于iis站点无法读取 服务器共享目录的问题
  7. noaman日志第一条:2015-1024;“Hello.World”
  8. CAP原则(CAP定理)
  9. symbol(s) not found for architecture x86_64
  10. [MODx] 6. Cache &#39;!&#39; with login package
  11. winform/wpf 程序部署
  12. JS 继承(类式 与 原型式)
  13. EventEmitter事件处理器中的this问题
  14. hdu4276 依赖背包
  15. 字定义JSON序列化支持datetime格式序列化
  16. 基于报错的SQL注入整理
  17. algebraically closed field 代数闭域
  18. Subordinates CodeForces - 737C (树,构造)
  19. Linux -- 基于zookeeper的java api(一)
  20. chandy-lamport 分布式一致性快照 算法详细介绍

热门文章

  1. 揭秘 Flink 1.9 新架构,Blink Planner 你会用了吗?
  2. (转)第05节:Fabric.js的动画设置
  3. SGI STL rope
  4. System.Drawing.Imaging.ImageFormat.cs
  5. PAT甲级——A1108 Finding Average【20】
  6. 7_3.springboot2.x启动配置原理_3.事件监听机制
  7. USACO 2008 November Gold Cheering up the Cows /// MST oj24381
  8. (转)行为树(Behavior Tree)实践(1)– 基本概念
  9. mac brew 安装 php 环境
  10. 算法系列:Shell 排序