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. 暑期ACM集训

    2019-07-17 08:42:11 这是总结昨天的做题情况 总体来说,好久的没做题了,实力下降了许多,这一个月假又学习吧!!!! A - Ropewalkers Polycarp decided ...

  2. C#笔试题目总结

    基础 知识点 try catch finally的执行顺序(有return的情况下): 不管有没有出现异常,finally块中代码都会执行: 当try和catch中有return时,finally仍然 ...

  3. net技术方案

    https://www.cnblogs.com/qyq0323/p/11765243.html https://yq.aliyun.com/articles/300527

  4. VBA Excel对象(十九)

    使用VBA进行编程时,用户将要处理的重要对象很少.下面是一些常见的对象 - 应用程序对象 工作簿对象 工作表对象 范围对象 应用程序对象 应用程序对象由以下部分组成 - 应用程序范围的设置和选项. 返 ...

  5. 清楚html和css标签自带默认样式

    html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, ...

  6. Qt定时器

    PS: 本案例使用的是Qt 4.8.4版本,不同版本代码可能会有差异. 第一步: // 重写此虚函数(继承自QObject) virtual void timerEvent(QTimerEvent* ...

  7. [iOS]UIButton内、外边距设置

    - (void)viewDidLoad {        [super viewDidLoad];        /*         UIButton设置对应的边距image跟title的边距属性  ...

  8. awk 概述及常用方法总结

    awk 简介 awk是一个文本处理工具,通常用于处理数据并生成结果报告, awk的命名是它的创始人 Alfred Aho.Peter Weinberger和Brian Kernighan 姓氏的首个字 ...

  9. Docker Compose编排工具部署lnmp实践及理论(详细)

    目录 一.理论概述 编排 部署 Compose原理 二.使用docker compose 部署lnmp 三.测试 四.总结 一.理论概述 Docker Compose是一个定义及运行多个Docker容 ...

  10. 偶然发现的几个OPENWRT工具安装包

    https://rychly.gitlab.io/openwrt-packages/ 有心人已经打好包了,下载拿用 例如:dropbrute https://rychly.gitlab.io/open ...