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

  代码:

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<algorithm>
  4. #include<cstring>
  5. using namespace std;
  6. #define int long long
  7. #define cin(a) scanf("%lld",&a)
  8. #define cout1(a) printf("%lld\n",a)
  9. #define cout2(a) printf("%lld ",a)
  10. int a[65]={1,1};
  11. int f[600050][65];
  12. int m,n;
  13. void pre()
  14. {
  15. for(int q=2;q<=64;q++)
  16. a[q]=a[q-1]+a[q-2];
  17. }
  18. int tot;
  19. int work(int x,int y)
  20. {
  21. if(x==y)
  22. return x;
  23. int dx,dy;
  24. int tx=x,ty=y;
  25. int k1=++tot,k2=++tot;
  26. f[k1][0]=x,f[k2][0]=y;
  27. for(int q=1;;q++)
  28. {
  29. if(tx==1)
  30. {
  31. dx=q;
  32. break;
  33. }
  34. int l=lower_bound(a+1,a+64,tx)-a;
  35. if(tx<=a[l]) --l;
  36. f[k1][q]=tx-a[l];
  37. tx-=a[l];
  38. }
  39. for(int q=1;;q++)
  40. {
  41. if(ty==1)
  42. {
  43. dy=q;
  44. break;
  45. }
  46. int l=lower_bound(a+1,a+64,ty)-a;
  47. if(ty<=a[l]) --l;
  48. f[k2][q]=ty-a[l];
  49. ty-=a[l];
  50. }
  51. for(int q=0;;q++)
  52. if(f[k1][dx-q]!=f[k2][dy-q])
  53. return f[k1][dx-q+1];
  54. }
  55. signed main()
  56. {
  57. pre();
  58. cin(m);
  59. for(int q=1,x,y;q<=m;q++)
  60. {
  61. cin(x),cin(y);
  62. cout1(work(x,y));
  63. }
  64. }

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

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

代码:

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<algorithm>
  4. #include<cstring>
  5. using namespace std;
  6. #define int long long
  7. #define cin(a) scanf("%lld",&a)
  8. #define cout1(a) printf("%lld\n",a)
  9. #define cout2(a) printf("%lld ",a)
  10. int a[100]={1,1};
  11. int f[2][100];
  12. int m,n;
  13. void pre()
  14. {
  15. for(int q=2;q<=64;q++)
  16. a[q]=a[q-1]+a[q-2];
  17. }
  18. int tot;
  19. int work(int x,int y)
  20. {
  21. if(x==y)
  22. return x;
  23. int dx,dy;
  24. memset(f,0,sizeof(f));
  25. int tx=x,ty=y;
  26. int k1=0,k2=1;
  27. f[k1][0]=x,f[k2][0]=y;
  28. for(int q=1;;q++)
  29. {
  30. if(tx==1)
  31. {
  32. dx=q;
  33. break;
  34. }
  35. int l=lower_bound(a+1,a+64,tx)-a;
  36. if(tx<=a[l]) --l;
  37. f[k1][q]=tx-a[l];
  38. tx-=a[l];
  39. }
  40. for(int q=1;;q++)
  41. {
  42. if(ty==1)
  43. {
  44. dy=q;
  45. break;
  46. }
  47. int l=lower_bound(a+1,a+64,ty)-a;
  48. if(ty<=a[l]) --l;
  49. f[k2][q]=ty-a[l];
  50. ty-=a[l];
  51. }
  52. for(int q=0;;q++)
  53. if(f[k1][dx-q]!=f[k2][dy-q])
  54. return f[k1][dx-q+1];
  55. }
  56. signed main()
  57. {
  58. pre();
  59. cin(m);
  60. for(int q=1,x,y;q<=m;q++)
  61. {
  62. cin(x),cin(y);
  63. cout1(work(x,y));
  64. }
  65. }

T2:

  没思路,一点也没有……

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

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

  带修莫队啊

  不过,怎么打来着……

  没事,现场YY

  成功过样例了。

  结果TLE40。

  块长爆了

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

  仍是代码:

 

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<algorithm>
  4. #include<cstring>
  5. #include<cmath>
  6. using namespace std;
  7. #define cin(a) scanf("%d",&a)
  8. #define cout1(a) printf("%d\n",a)
  9. #define cout2(a) printf("%d ",a)
  10. const int maxn=3e5+5;
  11. struct node{
  12. int l,r,wh,tim,ans;
  13. }a[maxn];
  14. struct cha{
  15. int k,tim;
  16. }b[maxn];
  17. int tot1,tot2;
  18. int block[maxn];
  19. int t[maxn];
  20. int c[maxn];
  21. int l,r;
  22. int m,n;
  23. inline bool h233(node a,node b)
  24. {
  25. if(block[a.l]==block[b.l])
  26. return a.r<b.r;
  27. return block[a.l]<block[b.l];
  28. }
  29. inline bool h234(cha a,cha b)
  30. {
  31. return a.tim<b.tim;
  32. }
  33. inline bool h235(node a,node b)
  34. {
  35. return a.tim<b.tim;
  36. }
  37. inline void work(const int k)
  38. {
  39. register int bj;
  40. for(bj=1;;++bj)
  41. {
  42. register int p=b[bj].k;
  43. if(b[bj].tim>a[k].tim||bj>tot2)
  44. break;
  45. if(p==r)
  46. --t[c[p]],++t[c[p+1]];
  47. if(p==l-1)
  48. ++t[c[p]],--t[c[p+1]];
  49. c[p]^=c[p+1],c[p+1]^=c[p],c[p]^=c[p+1];
  50. }
  51. --bj;
  52. while(l<a[k].l) --t[c[l++]];
  53. while(l>a[k].l) ++t[c[--l]];
  54. while(r<a[k].r) ++t[c[++r]];
  55. while(r>a[k].r) --t[c[r--]];
  56. a[k].ans=t[a[k].wh];
  57. for(;bj;--bj)
  58. {
  59. int p=b[bj].k;
  60. if(p==r)
  61. --t[c[p]],++t[c[p+1]];
  62. if(p==l-1)
  63. ++t[c[p]],--t[c[p+1]];
  64. c[p]^=c[p+1],c[p+1]^=c[p],c[p]^=c[p+1];
  65. }
  66. }
  67. signed main()
  68. {
  69. cin(n),cin(m);
  70. int len=1+pow(n,0.666666);
  71. for(register int q=1;q<=n;++q)
  72. block[q]=(q-1)/len+1;
  73. for(register int q=1;q<=n;++q)
  74. cin(c[q]);
  75. for(register int q=1,x;q<=m;++q)
  76. {
  77. cin(x);
  78. if(x==1)
  79. {
  80. cin(a[++tot1].l),
  81. cin(a[tot1].r),
  82. cin(a[tot1].wh);
  83. a[tot1].tim=q;
  84. }
  85. else
  86. {
  87. cin(b[++tot2].k);
  88. b[tot2].tim=q;
  89. }
  90. }
  91. sort(a+1,a+tot1+1,h233);
  92. sort(b+1,b+tot2+1,h234);
  93. l=1,r=0;
  94. for(register int q=1;q<=tot1;++q)
  95. work(q);
  96. sort(a+1,a+tot1+1,h235);
  97. for(register int q=1;q<=tot1;++q)
  98. cout1(a[q].ans);
  99. }

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. Vue使用指南(三)

    组件 '''1.根组件:new Vue()创建的组件,一般不明确自身的模板,模板就采用挂载点2.局部组件: local_component = {}2.全局组件: Vue.component({})' ...

  2. drbd+nfs+keepalived

    写的很详细 理论知识: https://www.cnblogs.com/kevingrace/p/5740940.html 写的很详细 负载: https://www.cnblogs.com/kevi ...

  3. 怎样修改vim的缩进

    默认vim的tab缩进是八个空格, 太长了, 需要改短一点. 第一步: 找到vimrc文件所在位置 # find / -name vimrc 第二步: 找到以后用vim打开vimrc文件并增加下面两行 ...

  4. 基于NetCore+SqlSugar+Layui开发出来的开源框架项目FytSoaCms问题处理

    最近刚好在学习NetCore框架所以就在网上搜索了一下相关的开源框架项目,正好在Github上找到了一个不错的开源框架所以推荐给大家看看哈哈哈. 1:项目相关技术 运行NetCore SDK版本为2. ...

  5. vue 百度云上传文件PostObject

    百度云上传文件 API(PostObject) PostObject接口  : 接口描述 此接口使用HTML表单上传文件到指定bucket,用于实现通过浏览器上传文件到bucket.在PutObjec ...

  6. physdiskwrite 的简单使用

    physdiskwrite 的简单使用 参考  https://m0n0.ch/wall/physdiskwrite.php 来源 https://www.cnblogs.com/EasonJim/p ...

  7. [转载]Python 包管理工具

    [转载]Python 包管理工具 最近由于机缘巧合,使用各种方法安装了一些Python包,所以对Python的包管理开始感兴趣.在网上找到一篇很好的文章:https://blog.zengrong.n ...

  8. Html5知识精粹纪录

    1. HTML5文档的正文结构及新元素 正文结构: <header> <nav> <section> <aside> <footer> 深入 ...

  9. JVM锁优化以及区别

    偏向所锁,轻量级锁都是乐观锁,重量级锁是悲观锁. 首先简单说下先偏向锁.轻量级锁.重量级锁三者各自的应用场景: 偏向锁:只有一个线程进入临界区: 轻量级锁:多个线程交替进入临界区: 重量级锁:多个线程 ...

  10. mysql8.0授权远程登录

    之前一直用mysql5.6 远程授权登录,后来换mysql8.0原来的授权方式报错 mysql> grant all privileges on *.* to 'root'@'%' identi ...