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. 虚拟机VMware中安装Ubuntu18.04

    准备工作 Ubuntu 获取地址: 官网 清华镜像站 VMware 获取地址链接 安装过程 Vmware的安装过程此处不在赘述,不清楚如何安装的请自行百度,参见VMware14安装教程 然后就是Vmw ...

  2. Scala Actor入门

    介绍 Scala的Actor类似于Java中的多线程编程.但是不同的是,Scala的Actor提供的模型与多线程有所不同.Scala的Actor尽可能地避免锁和共享状态,从而避免多线程并发时出现资源争 ...

  3. 【计数DP】种树

    种树 题目描述 事实上,小X邀请两位奆老来的目的远不止是玩斗地主,主要是为了抓来苦力,替他的后花园种树……小X的后花园是环形的,他想在花园周围均匀地种上n棵树,但是奆老花园的土壤当然非同寻常,每个位置 ...

  4. CentOS 6.9安装配置nmon

    nmon是一款开源的性能监控工具,用于监控CentOS系统的资源消耗信息,并能把结果输出到文件中,然后通过nmon_analyser性能报告分析器生成数据分析报表. 一.安装nmon: 1. 配置ep ...

  5. 天梯赛 L3-002. 堆栈

    思路:这里的线段树维护一个区间里面出现数的个数,对于Pop,push单点更新一下就好. #include<stdio.h> #include<iostream> #includ ...

  6. Java反射机制、注解及JPA实现

    1.java反射概述 JAVA反射机制是在运行状态中,对于任意一个实体类,都能够知道这个类的所有属性和方法:对于任意一个对象,都能够调用它的任意方法和属性:这种动态获取信息以及动态调用对象方法的功能称 ...

  7. RCS版本控制

    RCS(Revision Control System)衍生品有两个 SCCS(Source Code Control System) CVS(Concurrent Versions System)是 ...

  8. Vue指令之`v-model`和`双向数据绑定

     v-bind 只能实现数据的单向绑定,从 M 自动绑定到 V, 无法实现数据的双向绑定 <input type="text" v-bind:value="msg& ...

  9. kvm虚拟机在线调整硬件配置

    #centos5.x版本不支持动态调整内存,CPU,以下是在centos6.x上测试 1.查看虚拟机信息 shell> virsh dumpxml cos_v1 | head -n 10 < ...

  10. 版本问题---Bazel与tensorflow的对应关系

    源码安装tf的时候,会用到Bazel,版本不对应,后面会引起好多麻烦. echo "deb [arch=amd64] http://storage.googleapis.com/bazel- ...