\(Rank\)


A - Rudolf and the Ticket

纯水题 暴力枚举直接过

$code$
  1. #include<bits/stdc++.h>
  2. #define fo(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)
  3. #define fu(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
  4. inline int qr()
  5. {
  6. char ch=getchar();int x=0,f=1;
  7. for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
  8. for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
  9. return x*f;
  10. }
  11. #define qr qr()
  12. typedef long long ll;
  13. using namespace std;
  14. const int Ratio=0;
  15. const int N=200005;
  16. const int maxx=INT_MAX;
  17. int T,n,m,k;
  18. int b[N],c[N];
  19. int main()
  20. {
  21. // freopen("1.in","r",stdin);
  22. // freopen("1.out","w",stdout);
  23. cin>>T;
  24. while(T--)
  25. {
  26. cin>>n>>m>>k;
  27. int cnt=0;
  28. for(int i=1;i<=n;i++)
  29. cin>>b[i];
  30. for(int i=1;i<=m;i++)
  31. cin>>c[i];
  32. for(int i=1;i<=n;i++)
  33. for(int j=1;j<=m;j++)
  34. if(b[i]+c[j]<=k)
  35. cnt++;
  36. printf("%d\n",cnt);
  37. }
  38. return Ratio;
  39. }

B - Rudolf and 121

题目中要求的是变换\(i\)同时修改两边的值

换个角度就是变换\(i-1\)的同时修改\(i\)和\(i+1\)

过一遍循环 当出现$a[i] $$<$$0$时标记并直接退出循环

输出\(YES\)的条件是没有标记并且\(a[n-1]\)和\(a[n]\)均为\(0\)

$code$
  1. #include<bits/stdc++.h>
  2. #define fo(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)
  3. #define fu(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
  4. inline int qr()
  5. {
  6. char ch=getchar();int x=0,f=1;
  7. for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
  8. for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
  9. return x*f;
  10. }
  11. #define qr qr()
  12. typedef long long ll;
  13. using namespace std;
  14. const int Ratio=0;
  15. const int N=200005;
  16. const int maxx=INT_MAX;
  17. int n;
  18. int a[N];
  19. int main()
  20. {
  21. // freopen("1.in","r",stdin);
  22. // freopen("1.out","w",stdout);
  23. int T=qr;
  24. while(T--)
  25. {
  26. n=qr;
  27. fo(i,1,n)
  28. a[i]=qr;
  29. bool fla=true;
  30. fo(i,1,n-2)
  31. {
  32. if(a[i]<0)
  33. {
  34. fla=false;
  35. break;
  36. }
  37. a[i+1]-=2*a[i];
  38. a[i+2]-=a[i];
  39. a[i]=0;
  40. }
  41. if(fla==true&&a[n-1]==0&&a[n]==0)
  42. printf("YES\n");
  43. else
  44. printf("NO\n");
  45. }
  46. return Ratio;
  47. }

C - Rudolf and the Ugly String

字符串!噔咚噔

还是较为简单的 毕竟是\(c\)题

简单观察后就能发现要求的字符串\(map\)和\(pie\)唯一结合的方式是变成\(mapie\) 不会出现重叠和套娃的情况

因此我们选用方便的\(substr\)来判定以下情况:

  1. 若前方存在\(mapie\) 则答案++ 同时向右走\(5\)位

  2. 其次 若前方存在\(map\)或\(pie\) 答案++ 同时向右走\(3\)位

  3. 否则 向右走\(1\)位

$code$
  1. #include<bits/stdc++.h>
  2. #define fo(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)
  3. #define fu(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
  4. inline int qr()
  5. {
  6. char ch=getchar();int x=0,f=1;
  7. for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
  8. for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
  9. return x*f;
  10. }
  11. #define qr qr()
  12. typedef long long ll;
  13. using namespace std;
  14. const int Ratio=0;
  15. const int N=200005;
  16. const int maxx=INT_MAX;
  17. int n,cnt;
  18. string s;
  19. int main()
  20. {
  21. // freopen("1.in","r",stdin);
  22. // freopen("1.out","w",stdout);
  23. int T=qr;
  24. while(T--)
  25. {
  26. n=qr;
  27. cin>>s;
  28. cnt=0;
  29. int i=0;
  30. while(i<n)
  31. {
  32. if(i+5<=n&&s.substr(i,5)=="mapie")
  33. cnt++,i+=5;
  34. else if(i+3<=n&&s.substr(i,3)=="map")
  35. cnt++,i+=3;
  36. else if(i+3<=n&&s.substr(i,3)=="pie")
  37. cnt++,i+=3;
  38. else
  39. i++;
  40. }
  41. printf("%d\n",cnt);
  42. }
  43. return Ratio;
  44. }

D - Rudolf and the Ball Game

一眼转圈问题 这道题难在有个"\(?\)" 直接暴力\(dfs\)会在第\(3\)个测试点\(T\)掉

接下来 请出本场\(MVP\) :\(set!\)

众所周知(其实我\(T\)了好久才想起来 \(set\)的特性是维护一个严格单调递增的数列 但本题选用它的原因主要在 它会自动删除重复的元素!

因此 在这道可能性很多且易重复的题里面 \(set\)成为了比剪枝\(dfs\)更好的选择

学习\(set\)请自行跳转\(cppreference\)和\(CSDN\)

$code$
  1. #include<bits/stdc++.h>
  2. #define fo(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)
  3. #define fu(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
  4. inline int qr()
  5. {
  6. char ch=getchar();int x=0,f=1;
  7. for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
  8. for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
  9. return x*f;
  10. }
  11. #define qr qr()
  12. typedef long long ll;
  13. using namespace std;
  14. const int Ratio=0;
  15. const int N=200005;
  16. const int maxx=INT_MAX;
  17. int n,m,x;
  18. int dis;
  19. char c;
  20. int main()
  21. {
  22. // freopen("1.in","r",stdin);
  23. // freopen("1.out","w",stdout);
  24. int T=qr;
  25. while(T--)
  26. {
  27. n=qr,m=qr,x=qr;
  28. set<int>dh,yy;
  29. dh.insert(x-1);
  30. fo(i,1,m)
  31. {
  32. dis=qr;
  33. cin>>c;
  34. if(c=='0')
  35. for(auto i:dh)
  36. yy.insert((dis+i)%n);
  37. else if(c=='1')
  38. for(auto i:dh)
  39. yy.insert((i+n-dis)%n);
  40. else if(c=='?')
  41. for(auto i:dh)
  42. {
  43. yy.insert((dis+i)%n);
  44. yy.insert((i+n-dis)%n);
  45. }
  46. dh=yy;
  47. yy.clear();
  48. }
  49. printf("%d\n",dh.size());
  50. for(auto i:dh)
  51. printf("%d ",i+1);
  52. printf("\n");
  53. }
  54. return Ratio;
  55. }

E - Rudolf and k Bridges

一眼\(dp\) 关于它感觉不需要特别说明

首先 在输入桥时直接求出每一行的最优值

然后直接一个\(for\)找\(k\)个连续的较小值作答案即可

记得开\(long long\)!!!

插叙

第一遍

  1. const int maxx=INT_MAX;

第二遍

"哦 不对 是long long"

  1. const int maxx=1e18;

第三遍

  1. const ll maxx=1e18..

$code$
  1. #include<bits/stdc++.h>
  2. #define fo(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)
  3. #define fu(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
  4. inline int qr()
  5. {
  6. char ch=getchar();int x=0,f=1;
  7. for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
  8. for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
  9. return x*f;
  10. }
  11. #define qr qr()
  12. typedef long long ll;
  13. using namespace std;
  14. const int Ratio=0;
  15. const int N=200005;
  16. const ll maxx=1e18;
  17. int n,m,k,d;
  18. int dh[N];
  19. ll dp[N],cost[N];
  20. int main()
  21. {
  22. // freopen("1.in","r",stdin);
  23. // freopen("1.out","w",stdout);
  24. int T=qr;
  25. while(T--)
  26. {
  27. n=qr,m=qr,k=qr,d=qr;
  28. fo(k,1,n)
  29. {
  30. fo(i,1,m)
  31. dh[i]=qr,dp[i]=maxx;
  32. deque<pair<ll,ll> >q;//钱 位置
  33. dp[1]=1;
  34. q.push_back(make_pair(1,1));
  35. for(int i=2;i<=m;i++){
  36. dp[i]=min(dp[i],q.front().first+dh[i]+1);
  37. while(!q.empty()&&dp[i]<=q.back().first)
  38. q.pop_back();
  39. q.push_back(make_pair(dp[i],i));
  40. if(i-d>q.front().second)
  41. q.pop_front();
  42. }
  43. // cout<<dp[m]<<endl;
  44. cost[k]=dp[m];
  45. // cost[k]=cost[k-1]+dp[m];
  46. // cout<<cost[k]<<"||||||||"<<endl;
  47. }
  48. ll ans=maxx;
  49. fo(i,1,n-k+1)
  50. {
  51. ll res=0;
  52. fo(j,i,i+k-1)
  53. res+=cost[j];
  54. ans=min(ans,res);
  55. }
  56. printf("%lld\n",ans);
  57. }
  58. return Ratio;
  59. }

F - Rudolf and Imbalance

\(MVP\)再次登场

严格单增 完美契合\(set\)

一开始直接找初始\(a[N]\)中最大差和次大差

然后对最大差进行操作 用给的\(f\)和\(d\)操作将它分成两个尽量大的差 因为这样才能保证它们中较大的那个更小 更满足题意

然后还是\(long long\)

别的没什么太要紧的了 关于\(lower_{—} bound\)返回指针类型等的小点 我在代码中也加入了部分注释

$code$
  1. #include<bits/stdc++.h>
  2. #define fo(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)
  3. #define fu(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
  4. typedef long long ll;
  5. inline ll qr()
  6. {
  7. char ch=getchar();ll x=0,f=1;
  8. for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
  9. for(;ch>='0'&&ch<='9';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
  10. return x*f;
  11. }
  12. #define qr qr()
  13. using namespace std;
  14. const int Ratio=0;
  15. const int N=200005;
  16. const int maxint=INT_MAX;
  17. const ll maxll=1e18;
  18. int n,m,k;
  19. ll a[N];
  20. ll deta,detaa,lb,rb,ans;
  21. set<ll>f,d;
  22. int main()
  23. {
  24. // freopen("1.inll","r",stdin);
  25. // freopen("1.out","w",stdout);
  26. int T=qr;
  27. while(T--)
  28. {
  29. n=qr,m=qr,k=qr;
  30. f.clear(),d.clear();
  31. deta=0,detaa=0;
  32. fo(i,1,n)
  33. {
  34. a[i]=qr;
  35. if(i!=1)//输入时直接寻找最大差和次小差
  36. if(deta<a[i]-a[i-1])
  37. {
  38. detaa=deta;
  39. deta=a[i]-a[i-1];
  40. lb=a[i-1],rb=a[i];
  41. //由于单增排序 左边界为小
  42. }
  43. else if(detaa<a[i]-a[i-1])
  44. detaa=a[i]-a[i-1];
  45. }
  46. fo(i,1,m)
  47. {
  48. ll dd=qr;
  49. d.insert(dd);
  50. }
  51. fo(i,1,k)
  52. {
  53. ll ff=qr;
  54. f.insert(ff);
  55. }
  56. ans=deta;
  57. for(auto i:f)
  58. {
  59. auto dh=d.lower_bound((lb+rb)/2-i),yy=dh;
  60. //找最接近中间的 分开后两差大的尽量小
  61. ll dh1=*dh,yy1=*yy;
  62. //lower_bound值是指针类型无法运算 加*
  63. ans=min(ans,max(dh1+i-lb,rb-i-dh1));
  64. if(yy!=d.begin())
  65. //不是队首 指针需向上取 保证答案最优
  66. {
  67. yy--;
  68. yy1=*yy;
  69. ans=min(ans,max(yy1+i-lb,rb-i-yy1));
  70. }
  71. }
  72. cout<<max(detaa,ans)<<endl;
  73. //此时再次比较次大值和更改后最大值
  74. }
  75. return Ratio;
  76. }//

G - Rudolf and Subway

太蒻了 还没做出来。。

CF933-Div3 大致思路+题解的更多相关文章

  1. Egret学习笔记 (Egret打飞机-1.大致思路)

    大致看了一遍Egret的官方文档,就开始打算使用Egret来开发一个打飞机游戏. 首先来捋一捋思路,先来看一看一个打飞机游戏的图片 基本上一个打飞机游戏分为 开始游戏   ----------进入游戏 ...

  2. 发送邮件使用html模板的实现的大致思路

    客户最近有一个需求,大致的意思是提供一个 word文档,让其作为一个模板,在发送邮件的时候能够实现按照这个模板的样式和内容,替换其中 的一些字段,作为邮件的内容发给收件人.这个需求最大的问题就是在于这 ...

  3. SVM大致思路整理

    (一)线性可分 我们忽略建立目标函数的过程,直接写出目标函数. 原问题: 首先,我们得到了目标函数: 这是一个凸优化问题,直接可以用软件可以求解: 对偶问题: 原问题根据一系列的变换,可写成: 满足某 ...

  4. 前端标签--js--css大致思路

    html标签语言在块级和内联标签的基础上进行页面的设计,设计的时候主要是注意标签块间的距离位置等信息,设计盒子的浮动,盒子的位置,盒子之间的联系. 在设计网页之前一定要判断好该设计多少个盒子,什么样的 ...

  5. WCF入门大致思路

    WCF服务: 1.IServer.cs(类似接口,WCF接口) 2.Server.svc(实现了WCF接口)右键浏览器运行可以看到WCF服务链接,类似(http://localhost:4609/Us ...

  6. 【小白入门向】tarjan算法+codevs1332上白泽慧音 题解报告

    一.[前言]关于tarjan tarjan算法是由Robert Tarjan提出的求解有向图强连通分量的算法. 那么问题来了找蓝翔!(划掉)什么是强连通分量? 我们定义:如果两个顶点互相连通(即存在A ...

  7. 算法(第四版)C# 习题题解——2.3

    写在前面 整个项目都托管在了 Github 上:https://github.com/ikesnowy/Algorithms-4th-Edition-in-Csharp 查找更为方便的版本见:http ...

  8. dp方法论——由矩阵相乘问题学习dp解题思路

    前篇戳:dp入门——由分杆问题认识动态规划 导语 刷过一些算法题,就会十分珍惜“方法论”这种东西.Leetcode上只有题目.讨论和答案,没有方法论.往往答案看起来十分切中要害,但是从看题目到得到思路 ...

  9. 题解 P1436 【棋盘分割】

    题目链接 其实呢大致思路和下面的大佬们都很像.发这篇题解的目的就是加了一点~~优化~~骗分技巧. 转移方程: 设$dp[i][j][x][y][k]$表示左上$(i,j)$,右下$(x,y)$,第$k ...

  10. 题解 P3717 【[AHOI2017初中组]cover】

    题目链接 本题的大致思路就是搜索. 将矩阵初始化成false.先把灯塔标记.在搜一遍灯塔能照到的点并标记.最后搜一遍找被灯塔标记的个数. 详细解释见题解. 题解走起. #include<bits ...

随机推荐

  1. 本周四晚19:00知识赋能第七期第2课丨OpenHarmony WiFi扫描仪UX设计

    8月18日19:00~20:00,第七期知识赋能第二节直播就要开始啦!如果你是缺乏实战经验的学生,如果你是初出茅庐的职场新人,如果你是想参与开源的贡献者,那么本期的直播课将不容错过!通过本期直播,开发 ...

  2. 深入理解 SQL UNION 运算符及其应用场景

    SQL UNION运算符 SQL UNION运算符用于组合两个或多个SELECT语句的结果集. 每个UNION中的SELECT语句必须具有相同数量的列. 列的数据类型也必须相似. 每个SELECT语句 ...

  3. Avalonia的模板控件(Templated Controls)

    在Avalonia的UI框架中,TemplatedControl是一个核心组件,它提供了一种强大的方式来创建可重用且高度可定制的控件. 本文将深入探讨TemplatedControl的概念.其带来的优 ...

  4. std::string 拼接字符串

    #include <iostream> #include <string> #include <sstream> int main() { // 方法一:12345 ...

  5. redis 简单整理——缓存设计[三十二]

    前言 简单整理一下缓存设计. 正文 缓存的好处: ·加速读写:因为缓存通常都是全内存的(例如Redis.Memcache),而 存储层通常读写性能不够强悍(例如MySQL),通过缓存的使用可以有效 地 ...

  6. 单链表之删除头结点,查找等于定值x的结点数,单链表的逆置

    /* * @Author: 一届书生 * @Date: 2020-03-08 09:52:27 * @LastEditTime: 2020-03-08 13:58:30 */ #include < ...

  7. Node.js 中的事件循环机制

    一.是什么 在浏览器事件循环中,我们了解到javascript在浏览器中的事件循环机制,其是根据HTML5定义的规范来实现 而在NodeJS中,事件循环是基于libuv实现,libuv是一个多平台的专 ...

  8. Django框架——cookie与session简介、django操作cookie与session、django中间件

    cookie与session简介 """ 回忆:HTTP协议四大特性 1.基于请求响应 2.基于TCP.IP作用于应用层之上的协议 3.无状态 不保存客户端的状态 4.无 ...

  9. 【笔记】报错:numeric or value error: character to number conversion error

    报错:numeric or value error: character to number conversion error 报错如下: 数据库操作错误."2327,13619/v1:65 ...

  10. 阿里云安全运营中心:DDoS攻击趁虚而入,通过代理攻击已成常态

    应用层DDoS攻击与传统的DDoS攻击有着很大不同.传统的DDoS攻击通过向攻击目标发起大流量并发式访问造成服务不可用,系统瘫痪,这种方式比较容易被识破,且市场上已经有成熟的应对方案.而近年来兴起的应 ...