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

首先,题目有一个外衣,就是操作有版本的概念,他会进行存档和读档操作,但是我们知道,我们把操作建成一个树,他读档就是回到一个祖先,而对最终形态有影响的只有当前点到根的叠加操作。
那么我们就建一棵树,维护一个fa数组,最后不断跳祖先就知道了有效操作及顺序。
做法一:
用并查集维护当前行没染色的最右边的点。
我们把操作,逆序搞,因为后面染色的会覆盖前面染色的操作。
然后呢对于一段染过色的区间是不会被重复遍历的。
那么总的复杂度就是( 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;
}
做法二:
边栏推荐
- Part I physical layer
- [game theory complete information static game] strategic game
- Goland中在文件模板中为go文件添加个人声明
- JMeter load test finds the maximum number of concurrent users (including step analysis)
- Teach you how to use win7 system to quickly build your own website
- The e-sports Internet cafe uses a 2.5G network card to experience the feeling of flying!
- The scale of the global machine vision market continues to rise. Poe image acquisition card provides a high-speed transmission channel for industrial cameras
- 一个Golang的私有库设置问题
- Brain cell membrane equivalent neural network training code
- Diary at 16:29:41 on June 9, 2022
猜你喜欢

Live broadcast with practice | 30 minutes to build WordPress website with Alibaba cloud container service and container network file system

Why should I use iwarp, roce V2, nvme of and other protocols for 100g network transmission

Only 38 years old! Zhou Chuan, a researcher of the Chinese Academy of Sciences, died unfortunately. Rao Yi sent a document to mourn: he guided me when he was still my student

The secret of derating - don't challenge Datasheet

Solve the problem of img 5px spacing

Add personal statement for go file in file template in Golan
![[nk] 牛客练习赛100 C 小红的删数字](/img/f1/a99600e1800c087aceb60a559dee39.png)
[nk] 牛客练习赛100 C 小红的删数字

Use float to create a page header, footer, left content, and main content.

Release of version 5.6 of rainbow, add multiple installation methods, and optimize the topology operation experience

数据库每日一题---第9天:销售员
随机推荐
应用业务层修改
【C语言进阶】整型在内存中的存储
从概率论基础出发推导卡尔曼滤波
【指标体系】最新数仓指标体系建模方法
Only 38 years old! Zhou Chuan, a researcher of the Chinese Academy of Sciences, died unfortunately. Rao Yi sent a document to mourn: he guided me when he was still my student
二分图King
[index system] the latest modeling method of data warehouse index system
php pcntl_ Fork create multiple child process resolution
Why should I use iwarp, roce V2, nvme of and other protocols for 100g network transmission
New product release: lr-link Lianrui launched the first 25g OCP 3.0 network card
The official announced the launch of Alibaba's 2023 global school recruitment: Technical Posts account for more than 60%
[data visualization] use Apache superset to visualize Clickhouse data
机器视觉工控机PoE图像采集卡应用解析
一个Golang的私有库设置问题
One article to show you how to understand the harmonyos application on the shelves
RANSAC extract cylinder (matlab built-in function)
Application scenario: wide application of Poe network card in NDI technology for live broadcast program production
Live broadcast with practice | 30 minutes to build WordPress website with Alibaba cloud container service and container network file system
Explanation of each column output by explain statement
JUnit tests multithreaded code, and the sub thread does not run