\(T1\)旅行计划

不\(sb\)的题

比较显然转化成求一个点到所有点的最短路和

考虑我们非树边很少,那么可以把非树边连接的点看做是关键点,那么我们可以预处理每个关键点之间的最短路

我们每次询问,对询问点看做关键点,我们的路径肯定是关键点之间路径\(+\)树上路径,我们对于每个关键点的管控范围可以求出,那么我们最后求的是,一个点到所有关键点的权值\(+\)每个关键点对应联通块的子树贡献,可以把每个联通快统一处理,每次跑一遍类似虚树的东西,然后建立虚树时候顺便统计子树贡献即可,本质上大概也是个类似换根\(dp\)的东西,在每个关键点往外扩张的过程

\(T2\)搬砖

\(sb\)题,上午把式子推对了硬是没看出差分

//考虑这个维护的是什么
//我们维护区间连续的一段取模同余的最大模数
//假设只有两个数,我们的数字是abs(x-y)[x!=y]
//对于一个序列.我们的数字是一段区间所有相邻的gcd
//在这里,我已经得到了正解,tmd这是差分??????
//我没意识到...
//那么就很简单了,我们线段树维护区间差分gcd
//我们第二个修改时区间加,那么只需要改变两个位置
//第一个操作是区间变化直接打一个区间标记即可
//k=2a,m=a^2+b 区间gcd为gcd(kl+m,k)
#include<bits/stdc++.h>
#define int __int128
#define MAXN 200005
using namespace std;
int h[MAXN],n,q;
__int128 gcd(__int128 a,__int128 b)
{
if(a==0) return b;
if(b==0) return a;
return gcd(b,a%b);
}
int Abs(int a)
{
if(a>0) return a;
return -a;
}
namespace Seg1
{
#define ls (now<<1)
#define rs ((now<<1)|1)
struct Tr
{
int l,r,add,lza,lzb,lzc;
__int128 num;
bool lz;
}tr[MAXN<<2];
void build(int now,int l,int r)
{
tr[now].l=l;
tr[now].r=r;
if(l==r)
{
tr[now].num=h[l];
return ;
}
int mid=(l+r)>>1;
build(ls,l,mid);
build(rs,mid+1,r);
}
void pd(int now)
{
if(tr[now].lz)
{
int a=tr[now].lza;
int b=tr[now].lzb;
int c=tr[now].lzc;
tr[ls].lza=a; tr[ls].lzb=b; tr[ls].lzc=c; tr[ls].lz=true; tr[ls].add=0;
tr[ls].num=tr[ls].l*tr[ls].l*a+tr[ls].l*b+c;
tr[rs].lza=a; tr[rs].lzb=b; tr[rs].lzc=c; tr[rs].lz=true; tr[rs].add=0;
tr[rs].num=tr[rs].l*tr[rs].l*a+tr[rs].l*b+c;
tr[now].lza=tr[now].lzb=tr[now].lzc=0;
tr[now].lz=false;
}
if(tr[now].add)
{
int add=tr[now].add;
tr[ls].num+=add;
tr[ls].add+=add;
tr[rs].num+=add;
tr[rs].add+=add;
tr[now].add=0;
}
}
void Cover(int now,int l,int r,int a,int b,int c)
{
pd(now);
if(tr[now].l>=l&&tr[now].r<=r)
{
tr[now].lz=true;
tr[now].lza=a;
tr[now].lzb=b;
tr[now].lzc=c;
tr[now].add=0;
tr[now].num=tr[now].l*tr[now].l*a+tr[now].l*b+c;
pd(now);
return ;
}
int mid=(tr[now].l+tr[now].r)>>1;
if(l<=mid) Cover(ls,l,r,a,b,c);
if(r>mid) Cover(rs,l,r,a,b,c);
}
void change(int now,int l,int r,int c)
{
pd(now);
if(tr[now].l>=l&&tr[now].r<=r)
{
tr[now].add+=c;
tr[now].num+=c;
pd(now);
return ;
}
int mid=(tr[now].l+tr[now].r)>>1;
if(l<=mid) change(ls,l,r,c);
if(r>mid) change(rs,l,r,c);
}
int query(int now,int poz)
{
pd(now);
if(tr[now].l==poz&&tr[now].r==poz)
{
return tr[now].num;
}
int mid=(tr[now].l+tr[now].r)>>1;
if(poz<=mid) return query(ls,poz);
else return query(rs,poz);
}
}
namespace Seg2
{
#define ls (now<<1)
#define rs ((now<<1)|1)
struct Tr
{
int l,r,lza,lzb,lzc;
__int128 G;
bool lz;
}tr[MAXN<<2];
int GCD(int l,int r,int a,int b,int c)
{
return __gcd(2*a,2*a*l-a+b);
}
int val(int p,int a,int b,int c)
{
return p*p*a+p*b+c;
}
void upd(int now)
{
tr[now].G=gcd(tr[ls].G,tr[rs].G);
}
void build(int now,int l,int r)
{
tr[now].l=l;
tr[now].r=r;
if(l==r)
{
tr[now].G=Abs(h[l]-h[l+1]);
return ;
}
int mid=(l+r)>>1;
build(ls,l,mid);
build(rs,mid+1,r);
upd(now);
}
void pd(int now)
{
if(tr[now].lz)
{
int a=tr[now].lza;
int b=tr[now].lzb;
int c=tr[now].lzc;
int k=2*a;
int m=a*a+b;
tr[ls].lza=a; tr[ls].lzb=b; tr[ls].lzc=c; tr[ls].lz=true;
if(tr[ls].l!=tr[ls].r)tr[ls].G=GCD(tr[ls].l,tr[ls].r,a,b,c);
else tr[ls].G=Abs(val(tr[ls].l+1,a,b,c)-val(tr[ls].l,a,b,c)); tr[rs].lza=a; tr[rs].lzb=b; tr[rs].lzc=c; tr[rs].lz=true;
if(tr[rs].l!=tr[rs].r)tr[rs].G=GCD(tr[rs].l,tr[rs].r,a,b,c);
else tr[rs].G=Abs(val(tr[rs].l+1,a,b,c)-val(tr[rs].l,a,b,c));
tr[now].lz=false;
tr[now].lza=0; tr[now].lzb=0; tr[now].lzc=0;
}
}
/*
*/
void Cover(int now,int l,int r,int a,int b,int c)
{
// cout<<"Tr: "<<(long long)tr[now].l<<" "<<(long long)tr[now].r<<"\n";
if(tr[now].l>=l&&tr[now].r<=r)
{
// cout<<tr[now].l<<" tott "<<tr[now].r<<" "<<endl;
int k=2*a;
int m=a*a+b;
if(tr[now].l==tr[now].r)
{
tr[now].G=Abs(val(tr[now].r+1,a,b,c)-val(tr[now].l,a,b,c)); // cout<<"change "<<" "<<(long long)now<<" "<<(long long)tr[now].l+1<<" "<<(long long)tr[now].r+1<<" "<<(long long)tr[now].G<<endl;
// cout<<a<<" "<<b<<" "<<c<<endl;
// cout<<"kok: "<<tr[now].l<<" "<<tr[now].r<<"\n";
return ;
}
tr[now].lz=true;
tr[now].lza=a;
tr[now].lzb=b;
tr[now].lzc=c;
tr[now].G=GCD(tr[now].l,tr[now].r,a,b,c);
// cout<<"here "<<tr[now].l<<" "<<tr[now].r<<" "<<(long long )tr[now].G<<endl;
return ;
}
pd(now);
int mid=(tr[now].l+tr[now].r)>>1;
if(l<=mid) Cover(ls,l,r,a,b,c);
if(r>mid) Cover(rs,l,r,a,b,c);
upd(now);
}
void change(int now,int poz,int k)
{
if(tr[now].l==poz&&tr[now].r==poz)
{
tr[now].G=k;
return ;
}
pd(now);
int mid=(tr[now].l+tr[now].r)>>1;
if(poz<=mid) change(ls,poz,k);
else change(rs,poz,k);
upd(now);
}
void debug(int now)
{
pd(now);
cout<<(long long)now<<" "<<(long long)tr[now].l<<" "<<(long long)tr[now].r<<" "<<((long long)tr[now].G)<<"\n";
if(tr[now].l!=tr[now].r)debug(ls),debug(rs);
}
}
void print(__int128 x)
{
int cnt=0;
signed Mid[100];
if(x==0)
{
cout<<0<<"\n";
return;
}
while(x)
{
Mid[++cnt]=x%10;
x/=10;
}
for(int i=cnt;i>=1;i--) cout<<Mid[i];
cout<<"\n";
}
int Read()
{
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-') f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
return x;
}
signed main()
{
n=Read(),q=Read();
// scanf("%lld%lld",&n,&q);
for(int i=1;i<=n;i++)
{
h[i]=Read();
// scanf("%lld",&h[i]);
}
Seg1::build(1,1,n);
Seg2::build(1,1,n-1);
for(long long i=1,op,l,r,a,b,c;i<=q;i++)
{
// cin>>op>>l>>r>>a>>b>>c;
op=Read(),l=Read(),r=Read(),a=Read(),b=Read(),c=Read();
// scanf("%lld%lld%lld%lld%lld%lld",&op,&l,&r,&a,&b,&c);
if(op==1)
{
Seg1::Cover(1,l,r,a,b,c);
// if(l-1)
if(r!=1) Seg2::Cover(1,l,max(r-1,1ll),a,b,c);
int res1,res2;
if(l-1>=1)
{
res1=Seg1::query(1,l-1);
res2=Seg1::query(1,l);
Seg2::change(1,l-1,Abs(res1-res2));
}
if(r+1<=n)
{
res1=Seg1::query(1,r);
res2=Seg1::query(1,r+1);
Seg2::change(1,r,Abs(res1-res2));
}
}
if(op==2)
{
Seg1::change(1,l,r,c);
int res1,res2;
if(l-1>=1)
{
res1=Seg1::query(1,l-1);
res2=Seg1::query(1,l);
Seg2::change(1,l-1,Abs(res1-res2));
}
if(r+1<=n)
{
res1=Seg1::query(1,r);
res2=Seg1::query(1,r+1);
Seg2::change(1,r,Abs(res1-res2));
}
}
print(Seg2::tr[1].G);
}
}

\(T3\)寻觅

\(sb\)题,暴力能水过去

//说句人话就是
//一个区间除了都是零否则至少有一个数只出现一次
//考虑最后的序列至少有一个数只能出现一次
//那么填满之后的序列必须有一个数出现一次
//贪心维护?
//反正最终序列必须有一个出现一次,不妨设第一个是1
//我们肯定是按顺序插入?
//或者是每一段区间至少被覆盖一次
//一段区间要不被左端点覆盖,要不被右端点覆盖,要不被中间点覆盖(废话)
//直接构造就行吧,为什么要有顺序?这样貌似限制更强
//那考虑顺序,我们要保证每时每刻都要被覆盖
//那么我们新增一个点
//那么我们和他相等的点的覆盖范围就要被截断
//我们要实时保证有的地方可以被覆盖
//而且0的位置可以忽略
//我们维护一个每个数字维护一个set
//然后实时更新覆盖范围,最多n^2个我们每次至多n^2,n^3上限达不到
//乘个24的小常数
//盲猜正解直接转化成二维区间加减了,询问区间和是否等于0
#include<bits/stdc++.h>
#define MAXN 8505
using namespace std;
int cov[MAXN][MAXN],Fin[MAXN],p[MAXN],T;
set<int>Num[25];
void solve(int poz)
{
for(int i=1;i<=24;i++)
{
int l=*(--lower_bound(Num[i].begin(),Num[i].end(),poz));
int r=(*upper_bound(Num[i].begin(),Num[i].end(),poz));
int ll=*(--lower_bound(Num[i].begin(),Num[i].end(),l));
int rr=*(upper_bound(Num[i].begin(),Num[i].end(),r));
bool flag=true;
for(int j=l;j>ll;j--)
{
for(int k=poz;k<r;k++)
{
if(cov[j][k]<=1)
{
flag=false;
goto EB;
}
}
}
for(int j=poz;j>l;j--)
{
for(int k=r;k<rr;k++)
{
if(cov[j][k]<=1)
{
flag=false;
goto EB;
}
}
}
EB:
if(flag)
{
Fin[poz]=i;
Num[i].insert(poz);
for(int j=l;j>ll;j--)
{
for(int k=poz;k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13,1,2};
void sub2()
{
for(int i=1;i<=n;i++)
{
cout<<A[i]<<" ";
}
cout<<"\n";
}
void sol()
{
scanf("%d",&n);
memset(cov,0,sizeof(cov));
for(int i=1;i<=24;i++)
{
while(Num[i].size()) Num[i].erase(Num[i].begin());
Num[i].insert(0);
Num[i].insert(n+1);
}
bool flag=true;
for(int i=1;i<=n;i++)
{
scanf("%d",&p[i]);
if(p[i]!=i) flag=false;
}
if(flag)
{
sub2();
return ;
}
for(int i=1;i<=n;i++)
{
solve(p[i]);
}
for(int i=1;i<=n;i++)
{
cout<<Fin[i]<<" ";
}
cout<<"\n";
}
int main()
{
scanf("%d",&T);
while(T--) sol();
}

5.25 NOI 模拟的更多相关文章

  1. 5.30 NOI 模拟

    $5.30\ NOI $模拟 高三大哥最后一次模拟考了,祝他们好运 \(T1\)装箱游戏 显然可以将四种字母之间的空缺当做状态枚举 那么这道题就很显然了 #include<bits/stdc++ ...

  2. 5.23 NOI 模拟

    $5.23\ NOI $模拟 \(T1\)简单的计算几何题 \(zjr:\)我当时没改,那么自己看题解吧 倒是有个简单的随机化方法(能获得\(72pts,\)正确性未知)\(:\) 随机两条切椭圆的平 ...

  3. 5.6 NOI模拟

    \(5.6\ NOI\)模拟 明天就母亲节了,给家里打了个电话(\(lj\ hsez\)断我电话的电,在宿舍打不了,只能用教练手机打了) 其实我不是很能看到自己的\(future,\)甚至看不到高三的 ...

  4. 5.4 NOI模拟

    \(5.4\ NOI\)模拟 \(T1\) 想到分讨,但是暴力输出一下方案之后有很多特别的情况要讨论,就弃了... 假设\(a\)是原序列,\(b\)是我们得到的序列 设\(i\)是最长公共前缀,\( ...

  5. NOI模拟赛 Day1

    [考完试不想说话系列] 他们都会做呢QAQ 我毛线也不会呢QAQ 悲伤ING 考试问题: 1.感觉不是很清醒,有点困╯﹏╰ 2.为啥总不按照计划来!!! 3.脑洞在哪里 4.把模拟赛当作真正的比赛,紧 ...

  6. PAT 1002. A+B for Polynomials (25) 简单模拟

    1002. A+B for Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue T ...

  7. PAT甲题题解-1109. Group Photo (25)-(模拟拍照排队)

    题意:n个人,要拍成k行排队,每行 n/k人,多余的都在最后一排. 从第一排到最后一排个子是逐渐增高的,即后一排最低的个子要>=前一排的所有人 每排排列规则如下: 1.中间m/2+1为该排最高: ...

  8. NOI 模拟赛 #2

    得分非常惨惨,半个小时写的纯暴力 70 分竟然拿了 rank 1... 如果 OYJason 和 wxjor 在可能会被爆踩吧 嘤 T1 欧拉子图 给一个无向图,如果一个边集的导出子图是一个欧拉回路, ...

  9. 【2018.12.10】NOI模拟赛3

    题目 WZJ题解 大概就是全场就我写不过 $FFT$ 系列吧……自闭 T1 奶一口,下次再写不出这种 $NTT$ 裸题题目我就艹了自己 -_-||| 而且这跟我口胡的自创模拟题 $set1$ 的 $T ...

随机推荐

  1. 2. springboot加载配置参数顺序

    加载顺序依次是:1.jar的classes里面的application.properties 2.当前路径下config里面的application.properties 3.jar的classes里 ...

  2. 好客租房21-react组件的两种创建方式(函数组件)

    1使用函数创建组件 函数组件:使用js的函数或者箭头函数创建的组件 约定1:函数组件名称必须以 开头 约定2:函数组件必须有返回值 表示该组件的结构 如果返回值为null 表示不渲染任何内容 2.1使 ...

  3. Zookeeper安装学习(一)

    学习内容:Zookeeper本地安装 前提准备:①JDK安装成功 ②通过XShell7将Zookeeper安装包(apache-zookeeper-3.5.7-bin.tar.gz)拷贝到Linux系 ...

  4. 个人冲刺(一)——体温上报app(二阶段)

    冲刺任务:完成app登录和注册页面的布局 activity_register.xml <?xml version="1.0" encoding="utf-8&quo ...

  5. Stream.toList()和Collectors.toList()的性能比较

    昨天给大家介绍了Java 16中的Stream增强,可以直接通过toList()来转换成List. 主要涉及下面这几种转换方式: list.stream().toList(); list.stream ...

  6. AGC007E Shik and Travel 解题报告

    AGC007E Shik and Travel 题目大意:\(n\) 个点的二叉树,每个点要么两个儿子,要么没有儿子,每条边有边权. 你从 \(1\) 号节点出发,走到一个叶子节点.然后每一天,你可以 ...

  7. HashMap高阶用法,十倍提升开发效率

    HashMap在工作中使用非常频繁,其实在JDK1.8的时候新增一些更高阶的用法,熟练使用这些方法可以大大提升开发效率,写出更简洁优美的代码. 1. get方法指定返回默认值(getOrDefault ...

  8. Java编码安全

    目录 Java编码安全 数据校验 规则1.1:校验跨信任边界传递的不可信数据 规则1.2:禁止直接使用不可信数据来拼接SQL语句 规则1.4:禁止直接使用不可信数据来记录数据 规则1.6:验证路径前将 ...

  9. 如何正确理解古典概率中的条件概率 《考研概率论学习之我见》 -by zobol

    "B事件发生的条件下,A事件发生的概率"? "在A集合内有多少B的样本点"? "在B约束条件下,A发生的概率变化为?" "B事件中 ...

  10. 『忘了再学』Shell流程控制 — 35、多分支case条件语句

    目录 1.case条件语句介绍 2.case语句需要注意的内容 3.练习 示例1 示例2 1.case条件语句介绍 case语句和if-elif-else语句一样都是多分支条件语句,不过和if多分支条 ...