rank25凉凉好吧。。。。。。
T1:。。。
        一开始完全**
        手玩给的那张图(不放图,我太饿把图吃了)
        发现对于任一个节点,减去上一个比他小的斐波那契数就是父节点,
        于是,欢乐敲代码(话说别人好像是二分查找,而我直接打表+lower_bound,<algorithm>大法好)
        过编译,于是……
        样例死了。绝望.png
        一个小时后,过了。
        结果MLE80好吧。

  代码:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define int long long
#define cin(a) scanf("%lld",&a)
#define cout1(a) printf("%lld\n",a)
#define cout2(a) printf("%lld ",a)
int a[65]={1,1};
int f[600050][65];
int m,n;
void pre()
{
for(int q=2;q<=64;q++)
a[q]=a[q-1]+a[q-2];
}
int tot;
int work(int x,int y)
{
if(x==y)
return x;
int dx,dy;
int tx=x,ty=y;
int k1=++tot,k2=++tot;
f[k1][0]=x,f[k2][0]=y;
for(int q=1;;q++)
{
if(tx==1)
{
dx=q;
break;
}
int l=lower_bound(a+1,a+64,tx)-a;
if(tx<=a[l]) --l;
f[k1][q]=tx-a[l];
tx-=a[l];
}
for(int q=1;;q++)
{
if(ty==1)
{
dy=q;
break;
}
int l=lower_bound(a+1,a+64,ty)-a;
if(ty<=a[l]) --l;
f[k2][q]=ty-a[l];
ty-=a[l];
}
for(int q=0;;q++)
if(f[k1][dx-q]!=f[k2][dy-q])
return f[k1][dx-q+1];
} signed main()
{
pre();
cin(m);
for(int q=1,x,y;q<=m;q++)
{
cin(x),cin(y);
cout1(work(x,y));
}
}

P.S.如果哪位知道我为什么MLE,欢迎告诉来骂我

updata:已A,可改为滚动数组

代码:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define int long long
#define cin(a) scanf("%lld",&a)
#define cout1(a) printf("%lld\n",a)
#define cout2(a) printf("%lld ",a)
int a[100]={1,1};
int f[2][100];
int m,n;
void pre()
{
for(int q=2;q<=64;q++)
a[q]=a[q-1]+a[q-2];
}
int tot;
int work(int x,int y)
{
if(x==y)
return x;
int dx,dy;
memset(f,0,sizeof(f));
int tx=x,ty=y;
int k1=0,k2=1;
f[k1][0]=x,f[k2][0]=y;
for(int q=1;;q++)
{ if(tx==1)
{
dx=q;
break;
}
int l=lower_bound(a+1,a+64,tx)-a;
if(tx<=a[l]) --l;
f[k1][q]=tx-a[l];
tx-=a[l];
}
for(int q=1;;q++)
{
if(ty==1)
{
dy=q;
break;
}
int l=lower_bound(a+1,a+64,ty)-a;
if(ty<=a[l]) --l;
f[k2][q]=ty-a[l];
ty-=a[l];
}
for(int q=0;;q++)
if(f[k1][dx-q]!=f[k2][dy-q])
return f[k1][dx-q+1];
}
signed main()
{
pre();
cin(m);
for(int q=1,x,y;q<=m;q++)
{
cin(x),cin(y);
cout1(work(x,y));
}
}

T2:

  没思路,一点也没有……

  想开权值线段树,感觉MLE稳了

  突然发现修改、撤销、查询全是$ \Theta(1) $的,于是高兴了

  带修莫队啊

  不过,怎么打来着……

  没事,现场YY

  成功过样例了。

  结果TLE40。

  块长爆了

  过往的人啊,请牢记,带修莫队块长是$n^{  \frac {2} {3} }$

  仍是代码:

 

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define cin(a) scanf("%d",&a)
#define cout1(a) printf("%d\n",a)
#define cout2(a) printf("%d ",a)
const int maxn=3e5+5;
struct node{
int l,r,wh,tim,ans;
}a[maxn];
struct cha{
int k,tim;
}b[maxn];
int tot1,tot2;
int block[maxn];
int t[maxn];
int c[maxn];
int l,r;
int m,n;
inline bool h233(node a,node b)
{
if(block[a.l]==block[b.l])
return a.r<b.r;
return block[a.l]<block[b.l];
}
inline bool h234(cha a,cha b)
{
return a.tim<b.tim;
}
inline bool h235(node a,node b)
{
return a.tim<b.tim;
}
inline void work(const int k)
{
register int bj;
for(bj=1;;++bj)
{
register int p=b[bj].k;
if(b[bj].tim>a[k].tim||bj>tot2)
break;
if(p==r)
--t[c[p]],++t[c[p+1]];
if(p==l-1)
++t[c[p]],--t[c[p+1]];
c[p]^=c[p+1],c[p+1]^=c[p],c[p]^=c[p+1];
}
--bj;
while(l<a[k].l) --t[c[l++]];
while(l>a[k].l) ++t[c[--l]];
while(r<a[k].r) ++t[c[++r]];
while(r>a[k].r) --t[c[r--]];
a[k].ans=t[a[k].wh];
for(;bj;--bj)
{
int p=b[bj].k;
if(p==r)
--t[c[p]],++t[c[p+1]];
if(p==l-1)
++t[c[p]],--t[c[p+1]];
c[p]^=c[p+1],c[p+1]^=c[p],c[p]^=c[p+1];
}
}
signed main()
{
cin(n),cin(m);
int len=1+pow(n,0.666666);
for(register int q=1;q<=n;++q)
block[q]=(q-1)/len+1;
for(register int q=1;q<=n;++q)
cin(c[q]);
for(register int q=1,x;q<=m;++q)
{
cin(x);
if(x==1)
{
cin(a[++tot1].l),
cin(a[tot1].r),
cin(a[tot1].wh);
a[tot1].tim=q;
}
else
{
cin(b[++tot2].k);
b[tot2].tim=q;
}
}
sort(a+1,a+tot1+1,h233);
sort(b+1,b+tot2+1,h234);
l=1,r=0;
for(register int q=1;q<=tot1;++q)
work(q);
sort(a+1,a+tot1+1,h235);
for(register int q=1;q<=tot1;++q)
cout1(a[q].ans);
}

T3:

   没啥想说的,真没啥想说的,暴力都不会,水8分放弃


于是,结束了。

exam8.3的更多相关文章

  1. exam8.29

    咕了好几篇后... 我终于开始重新写了 T1: 不会,没思路,暴搜还可能会(一开始我以为暴搜时间复杂度为$\Theta (mn ^ k)$) 于是码出了暴搜... 跑一遍$(4,4,5)$,然后... ...

  2. Applet web端对文件的读取方式

    转载:http://www.exam8.com/computer/Java/zonghe/200708/659876.html ---- 我们知道,在Java Applet中出于安全性考虑,Apple ...

  3. laravel7 百度智能云检测内容及图片

    1:百度智能云,获取AppID,API Key,Secret Key https://console.bce.baidu.com/ai/?_=1642339692640&exraInfo=ai ...

随机推荐

  1. 机器学习之Adaboost与XGBoost笔记

    提升的概念 提升是一个机器学习技术,可以用于回归和分类问题,它每一步产生一个弱预测模型(如决策树),并加权累加到总模型中:如果每一步的弱预测模型生成都是依据损失函数的梯度方向,则称之为梯度提升(Gra ...

  2. 将springboot项目移到内网出现的问题!

    报找不到Jay包错误,在pom.xml文件中加这段 <repositories> <repository> <id>central</id> <u ...

  3. windows主机上ORACLE生成awr报告的步骤

    oracle数据库是一个大型的关系型数据库,那么如果有一天装载数据库的主机由于大量的IO操作导致主机cpu荷载超过100%会使得主机卡顿或者对数据库连接或者进行数据库进行正常的IO操作都会产生影响,所 ...

  4. 写一个vue的滚动条插件

    组件源码如下: vue-scroll.vue <template> <div class="vue-scroll" ref="vueScrollW&qu ...

  5. springboot 使用consul 读取配置文件(遇到的坑太多,没记录)

    最终成功版. pom引入mavn依赖: <!--consul--> <dependency> <groupId>org.springframework.cloud& ...

  6. VsCode开发Angular的必备插件

    1 概述 一般个人开发或者小公司开发都会使用破解版软件,除非比较尊重正版且不太缺钱的人才会用正版,但是大型公司有严格的规定,不允许员工使用盗版软件. 这时候我就不得不从WebStorm转向VsCode ...

  7. gradle上传jar包到maven公共仓库

    首先这里说的中央仓库 是指的 https://issues.sonatype.org/ 而不是maven私服. 其次是使用gradle上传jar包,maven上传,网上有很多教程,这里不做赘述. 首选 ...

  8. kvm第二章--虚拟机管理

  9. 用scrapy爬取京东商城的商品信息

    软件环境: gevent (1.2.2) greenlet (0.4.12) lxml (4.1.1) pymongo (3.6.0) pyOpenSSL (17.5.0) requests (2.1 ...

  10. NodeList和HTMLCollection区别

    关于DOM集合接口,主要不同在于HTMLCollection是元素集合而NodeList是节点集合(既包括元素,也包括节点). 规定一下结果是: . node.childNodes 结果返回类型是 N ...