当前位置:网站首页>BZOJ3189 : [Coci2011] Slika
BZOJ3189 : [Coci2011] Slika
2022-06-11 21:25:00 【dplovetree】
Slika
The question :

First , The title has a coat , It is the concept that the operation has version , He can archive and read files , But we know that , We build the operation into a tree , When he reads a document, he goes back to an ancestor , The only effect on the final shape is the stacking operation from the current point to the root .
Then we will build a tree , Maintain a fa Array , Finally, we can know the effective operation and sequence by constantly skipping our ancestors .
Practice one :
Maintain the rightmost point of the current row that is not stained with a union query set .
We put the operation , Reverse order , Because the operation of dyeing in the back will cover the operation of dyeing in the front .
Then, a colored interval will not be traversed repeatedly .
So the overall complexity is ( m ∗ n + n ∗ n m*n+n*n m∗n+n∗n).
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n,m) for(int i=n;i<=m;i++)
#define repp(i,n,m) for(int i=n;i>=m;i--)
int n,k,m;
char op[10];
int sa[100040];
int cnts=0,tot=0;
struct node{
int cl;
int x1,y1,x2,y2;
}z[100040];
queue<int>q;
int f[100050];
int fa[1010][1010];
int col[1004][1004];
int find(int x,int i){
if(x==fa[i][x])return x;
return fa[i][x]=find(fa[i][x],i);
}
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>k>>m;
int now=0;
for(int i=1;i<=m;i++){
cin>>op;
if(op[0]=='P'){
tot++;
cin>>z[tot].cl>>z[tot].x1>>z[tot].y1>>z[tot].x2>>z[tot].y2;
f[tot]=now;
now=tot;
}else if(op[0]=='S'){
cnts++;
sa[cnts]=now;
}else{
int a;
cin>>a;
now=sa[a];
}
}
for(int i=0;i<n+2;i++){
for(int j=0;j<n+2;j++)col[i][j]=1,fa[i][j]=j;
}
while(now){
int u=now;
for(int i=z[u].x1;i<=z[u].x2;i++){
int p;
if((i-z[u].x1)%2==0)p=find(z[u].y1,i);
else p=find(z[u].y1+1,i);
for(int j=p;j<=z[u].y2;j=find(j+2,i)){
fa[i][j]=j+2;
col[i][j]=z[u].cl;
}
}
now=f[now];
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)cout<<col[i][j]<<" ";
cout<<"\n";
}
return 0;
}
Practice two :
边栏推荐
- 实现 TabLayout 下标与文字等长,选中字体大小改变
- Using the sap ui5 cli command line tool to build and run SAP ui5 applications
- JVM|类加载器;双亲委派机制
- select _ Lazy loading
- Obsidian关系图谱如何让节点可以手动拖动
- ORA-04098: trigger ‘xxx.xxx‘ is invalid and failed re-validation
- LeetCode-155-最小栈
- Chain storage structure of linear table
- 2022年6月9日 16:29:41 日记
- Go语言for循环
猜你喜欢

Tensorflow 2. X Getting Started tutorial

第二部分 数据链路层

Three waves of changes in cloud computing
![Analysis on the development history and market development status of China's system integration industry in 2020 [figure]](/img/3c/b53c2a3f59ff6784f128cb98a5a7a2.jpg)
Analysis on the development history and market development status of China's system integration industry in 2020 [figure]

LeetCode-155-最小栈

Part II data link layer
![[Part 14] source code analysis and application details of completionservice class [key]](/img/41/9f5383d6eafb32723e29c15da3a1af.jpg)
[Part 14] source code analysis and application details of completionservice class [key]

Codeforces Round #744 (Div. 3) 解题报告

js对返回的数据的各种数据类型进行非空判断。

Test plans and test cases
随机推荐
LabVIEW控制Arduino实现超声波测距(进阶篇—5)
How to manually send events exposed by SAP commerce cloud mock application using SAP kyma console
Serval and Rooted Tree(CF1153D)-DP
【博弈论-完全信息静态博弈】 战略式博弈
Iros 2021 | new idea of laser vision fusion? Lidar intensity diagram +vpr
SQL的语法
RANSAC extract cylinder (matlab built-in function)
JVM方法区
关于gorm的preload方法笔记说明
JVM runtime constant pool and direct memory
LeetCode-43-字符串相乘
JVM|前言介绍
Part II data link layer
JVM|类加载器;双亲委派机制
如何创建最简单的 SAP Kyma Function
Brain cell membrane equivalent neural network training code
The official announced the launch of Alibaba's 2023 global school recruitment: Technical Posts account for more than 60%
Release of version 5.6 of rainbow, add multiple installation methods, and optimize the topology operation experience
关于斜率优化
Use float to create a page header, footer, left content, and main content.