A - Edge Checker 2

Problem Statement

Determine if there is a segment that directly connects the points numbered a and b in the figure below.

Constraints

  • 1≤a<b≤15
  • a and b are integers.

Input

The input is given from Standard Input in the following format:

a b

Output

Print Yes  if there is a segment that directly connects the points numbered a and b; print No otherwise.


Sample Input 1

1 2

Sample Output 1

Yes

In the figure in the Problem Statement, there is a segment that directly connects the points numbered 1 and 2, so Yes should be printed.


Sample Input 2

2 8

Sample Output 2

No

In the figure in the Problem Statement, there is no segment that directly connects the points numbered 2 and 8, so No should be printed.


Sample Input 3

14 15

Sample Output 3

No

AC Code:

#include <iostream>
#include <queue>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
int a, b;
int main()
{ios::sync_with_stdio(false);cin.tie(nullptr), cout.tie(nullptr);cin >> a >> b;if (b == a * 2 || b == a * 2 + 1)puts("Yes");elseputs("No");return 0;
}

B - Longest Uncommon Prefix

思路:朴素方法

AC Code:

#include <iostream>
#include <queue>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
int main()
{ios::sync_with_stdio(false);cin.tie(nullptr), cout.tie(nullptr);int n;string s;cin >> n >> s;for (int i = 1; i < n; i++){for (int j = 1; j <= n; j++){if (i + j > n){cout << j - 1 << "\n";break;}if (s[j - 1] == s[j + i - 1]){cout << j - 1 << "\n";break;}}}return 0;
}

C - abc285_brutmhyhiizp

 AC Code:

// 简单模拟
#include <iostream>
#include <queue>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
int main()
{ios::sync_with_stdio(false);cin.tie(nullptr), cout.tie(nullptr);string s;cin >> s;int l = s.size();long long res = 0, add = 26;for (int i = 1; i <= l - 1; i++){res += add;add *= 26;}long long num = 0;for (int i = 0; i < l; i++){num *= 26;num += (s[i] - 'A');}cout << res + num + 1;return 0;
}

F - Substring of Sorted String

AC Code:

#include<bits/stdc++.h>
using namespace std;#define lowbit(x) x&(-x)typedef long long ll;
const ll maxn=1e5+5;int n,q;char s[maxn];
int bit[30][maxn],sum[30],bit2[maxn];void add(int a[maxn],int x,int c) {for(int i=x;i<=n;i+=lowbit(i)) a[i]+=c;return ;
}int ask(int a[maxn],int x) {int res=0;for(int i=x;i>0;i-=lowbit(i)) res+=a[i];return res;
}void add2(int x,int c) {for(int i=x;i<n;i+=lowbit(i)) bit2[i]+=c;return ;
}int ask2(int x) {int res=0;for(int i=x;i>0;i-=lowbit(i)) res+=bit2[i];return res;
}int main() {ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);cin>>n>>s+1;for(int i=1;i<=n;i++) sum[s[i]-'a']++,add(bit[s[i]-'a'],i,1);for(int i=1;i<n;i++) if(s[i]<=s[i+1]) add2(i,1);cin>>q;for(int i=1,op;i<=q;i++) {cin>>op;if(op==1) {int x;char c;cin>>x>>c;sum[s[x]-'a']--,add(bit[s[x]-'a'],x,-1);if(x<n&&s[x]<=s[x+1]) add2(x,-1);if(x>1&&s[x-1]<=s[x]) add2(x-1,-1);s[x]=c;sum[s[x]-'a']++,add(bit[s[x]-'a'],x,1);if(x<n&&s[x]<=s[x+1]) add2(x,1);if(x>1&&s[x-1]<=s[x]) add2(x-1,1);}else {int l,r;cin>>l>>r;if(ask2(r-1)-ask2(l-1)!=r-l) {cout<<"No\n";continue;}int flag=0,tot=0;for(int j=0;j<26;j++) {int num=ask(bit[j],r)-ask(bit[j],l-1);tot+=num;if(!flag&&num==0) continue;if(!flag) flag=1;else {if(num<sum[j]&&tot!=r-l+1) {flag=-1;break;}}}if(flag==-1) cout<<"No\n";else cout<<"Yes\n";}}return 0;
}

AtCoder Beginner Contest 285解题报告相关推荐

  1. Atcoder Beginner Contest 124 解题报告

    心态爆炸.本来能全做出来的.但是由于双开了Comet oj一个比赛,写了ABC就去搞那个的B题 还被搞死了. 回来写了一会D就过了.可惜比赛已经结束了.真的是作死. A - Buttons #incl ...

  2. AtCoder Beginner Contest 132 解题报告

    前四题都好水.后面两道题好难. C Divide the Problems #include <cstdio> #include <algorithm> using names ...

  3. AtCoder Beginner Contest 285 青大蒟蒻训练日常(A-F) 上分场(可惜unr)

    比赛链接 A Edge Checker 2 线段树上判断a , b有边无边 , 先把层数低的放在a上,判断b/2 == a即可 提交 B Longest Uncommon Prefix 暴力 提交 C ...

  4. Atcoder Beginner Contest 260D - Draw Your Cards 解题报告

    Atcoder Beginner Contest 260D - Draw Your Cards 解题报告 1 题目链接 abc260_d 2 题目大意 题目 : 抽牌 题目大意 : 给定NNN个数字, ...

  5. AtCoder Beginner Contest 300G - P-smooth number解题报告

    AtCoder Beginner Contest 300G - P-smooth number解题报告 1 题目链接 传送门 2 题目大意 题目:P-光滑数的数量 题目大意: 在 1 1 1 到 n ...

  6. AtCoder题解 —— AtCoder Beginner Contest 182 —— D - Wandering

    题目相关 题目链接 AtCoder Beginner Contest 182 D 题,https://atcoder.jp/contests/abc182/tasks/abc182_d. Proble ...

  7. AtCoder题解 —— AtCoder Beginner Contest 187 —— B - Gentle Pairs —— 暴力

    题目相关 题目链接 AtCoder Beginner Contest 187 B 题,https://atcoder.jp/contests/abc187/tasks/abc187_b. Proble ...

  8. AtCoder题解—— AtCoder Beginner Contest 181 —— B - Trapezoid Sum

    题目相关 题目链接 AtCoder Beginner Contest 181 B 题,https://atcoder.jp/contests/abc181/tasks/abc181_b. Proble ...

  9. AtCoder Beginner Contest 282 A-E

    比赛名称:HHKB Programming Contest 2022 Winter(AtCoder Beginner Contest 282) 比赛链接:AtCoder Beginner Contes ...

最新文章

  1. 赠书福利 | Tidio AI 趋势报告:约42%受访者能够接受机器人伴侣
  2. python子类定制_在Python中实现可定制的Lexer类
  3. Dubbo学习总结(4)——Dubbo基于Zookeeper实现分布式实例
  4. 《An Introduction to Ray Tracing》——2.2 Ray/Sphere Intersection And Mapping
  5. php+pdo分页类
  6. ubuntu20.4 安装配置teamviewer
  7. 网络拓扑图(附华为、CiscoVisio图标)
  8. php微信图文分析数据库,获取某微信公众号所有文章且进行分析
  9. Gmail企业邮箱在用OUTLOK或FOXMAIL有时出现密码错误的解决办法
  10. 【Android Gradle 插件】 Splits 配置 ② ( Splits#abi{} 脚本块配置 | 根据 CPU 架构进行分包 | AbiSplitOptions 配置简介 )
  11. 百度BML飞桨训练营(五)商品种类识别
  12. 微软浏览器如何安装addon(插件)
  13. 看得更近,监督得更好:通过基于组件的鉴别器一次性生成字体
  14. 手机如何测光照度_照度测定方法
  15. 注册Google邮箱,也许你就差这一步
  16. python打印 字符串前面b
  17. Android8.1 MTK平台 Dialer修改(通话常亮、按钮接听)
  18. VirtualBox Installation failed! Error :安装时发生严重错误
  19. Hadoop的HA原理
  20. C++-二叉树递归遍历与非递归遍历实现

热门文章

  1. IT程序员的抉择:我要离开帝都了
  2. 冯东阳:5000元葬送了我的行业站点之梦
  3. awk和sed命令详解
  4. 多可文档管理系统_您的框架有多可扩展性?
  5. 智慧环保可视化决策系统
  6. C语言单链表,能直接运行的代码!
  7. 通信原理及系统系列33——无线信道(快衰落)
  8. 原理图库:元器件引脚命名如何输出上划线
  9. QQ2010去除迷你首页O(∩_∩)O
  10. Linux入门第三天——linux命令(二)