随笔分类 -  算法基础—思维题

摘要:题意是给一个01序列,允许进行一次操作,任选其中一个子序列,将其循环向右位移一次。之后问能否将这个序列划分为两个不相交的相等的子序列。 首先特判不可能的情况,即0和1的个数为奇数。之后两位两位考虑,假设相邻两位是00或者11,那么两个相等的数分别分给两个子序列即可。如果是01或者10,那么假设a子序 阅读全文
posted @ 2022-10-14 16:36 脂环 阅读(25) 评论(0) 推荐(0) 编辑
摘要:#include <bits/stdc++.h> #define int long long using namespace std; int n, c, q; string s; int l[45], r[45], len[45]; signed main() { int t; cin >> t; 阅读全文
posted @ 2022-07-16 19:59 脂环 阅读(46) 评论(0) 推荐(0) 编辑
摘要:A. Reverse and Concatenate 如果k为0直接输出1,否则如果s为回文串的话输出1,其他情况输出2(经过一次变换后必然为回文)。注意不能特判k = 1的情况,用这个样例hack了一发23333 #include <bits/stdc++.h> #define pii pair< 阅读全文
posted @ 2022-02-07 01:26 脂环 阅读(133) 评论(0) 推荐(0) 编辑
摘要:A. Div. 7 给一个数,问最少修改多少位可以让这个数被7整除。 注意到7小于10,因此每10个数必然有一个7,所以最多只需要修改一次个位即可。 #include <iostream> #include <cmath> #define ll long long using namespace s 阅读全文
posted @ 2022-02-01 17:42 脂环 阅读(65) 评论(0) 推荐(0) 编辑
摘要:A. 小沙的炉石 链接:https://ac.nowcoder.com/acm/contest/23477/A 来源:牛客网 题目描述 小沙热衷于玩决斗法,今天他和他的弟弟玩起了炉石,弟弟特别特别的菜,但是为了照顾弟弟的自尊心,所以小沙想要恰好将弟弟斩杀。 恰好斩杀:弟弟的血量恰好变成0。 小沙当前 阅读全文
posted @ 2022-01-26 23:56 脂环 阅读(87) 评论(0) 推荐(1) 编辑
摘要:A. Era 维护一个新数组的末尾位置变量pos,遍历的时候不断更新即可。 #include <iostream> #include <vector> #include <algorithm> #include <cstring> #include <map> #include <set> #def 阅读全文
posted @ 2021-10-31 00:40 脂环 阅读(154) 评论(2) 推荐(0) 编辑
摘要:Codeforces Round #750 (Div. 2) A. Luntik and Concerts c要么为奇数要么为偶数,同时a和b都大于1,如果c为奇数的话拿出一个1一个2就可以把所有的3都平均分了,如果是偶数的话所有的3能直接平均分。同理再把b尽力平均分掉... #include <i 阅读全文
posted @ 2021-10-24 22:24 脂环 阅读(165) 评论(0) 推荐(0) 编辑
摘要:Problem Description This summer, ZXyang became so tired when doing the problems of Multi-University contests. So he decided to attend the Unified Nati 阅读全文
posted @ 2021-07-29 17:13 脂环 阅读(93) 评论(0) 推荐(0) 编辑
摘要:Problem Description Chenjb is struggling with data stucture now. He is trying to solve a problem using segment tree. Chenjb is a freshman in programmi 阅读全文
posted @ 2021-07-27 23:16 脂环 阅读(97) 评论(0) 推荐(0) 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/11255/F 来源:牛客网 题目描述 Alice and Bob are playing a game. At the beginning, there is an undirected graph GG with nn 阅读全文
posted @ 2021-07-26 18:48 脂环 阅读(94) 评论(0) 推荐(0) 编辑
摘要:Problem Description Give you a cube with a side length of n-1. Find the number of equilateral triangles with three points on the cube point. Each side 阅读全文
posted @ 2021-07-23 10:42 脂环 阅读(320) 评论(0) 推荐(0) 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/11213/I 来源:牛客网 题目描述 在游戏中,因为一次错误的决断,你的士兵被敌方实行围剿。为了挽回人员损失,你不得不开启金手指暂停敌方士兵的移动,从而尽量让自己的士兵能成功突围。 已知地图是一块n×mn×m的区域,每块 阅读全文
posted @ 2021-07-16 22:42 脂环 阅读(229) 评论(0) 推荐(0) 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/11213/F 来源:牛客网 题目描述 在中国象棋中正所谓新手玩车,熟手玩炮,老手玩马,由此可见象棋中炮的地位还是比较高的。 给定一个n×mn×m的棋盘,全部摆满炮,我们视所有炮都不属于同一阵营,他们之间可以相互攻击但不能 阅读全文
posted @ 2021-07-16 22:38 脂环 阅读(200) 评论(0) 推荐(0) 编辑
摘要:Suppose you have two points 𝑝=(𝑥𝑝,𝑦𝑝)p=(xp,yp) and 𝑞=(𝑥𝑞,𝑦𝑞)q=(xq,yq). Let's denote the Manhattan distance between them as 𝑑(𝑝,𝑞)=|𝑥𝑝−� 阅读全文
posted @ 2021-07-15 20:02 脂环 阅读(360) 评论(0) 推荐(0) 编辑
摘要:AquaMoon had 𝑛n strings of length 𝑚m each. 𝑛n is an odd number. When AquaMoon was gone, Cirno tried to pair these 𝑛n strings together. After makin 阅读全文
posted @ 2021-07-13 12:03 脂环 阅读(114) 评论(1) 推荐(1) 编辑
摘要:AquaMoon has 𝑛n friends. They stand in a row from left to right, and the 𝑖i-th friend from the left wears a T-shirt with a number 𝑎𝑖ai written on 阅读全文
posted @ 2021-07-13 12:00 脂环 阅读(168) 评论(0) 推荐(0) 编辑
摘要:On a strip of land of length 𝑛n there are 𝑘k air conditioners: the 𝑖i-th air conditioner is placed in cell 𝑎𝑖ai (1≤𝑎𝑖≤𝑛1≤ai≤n). Two or more ai 阅读全文
posted @ 2021-07-11 11:51 脂环 阅读(154) 评论(0) 推荐(0) 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/11233/B 来源:牛客网 题目描述 给出一个仅包含 a,b 的字符串 A。在 A 中间任意位置(包括开头结尾)插入一个字符,最大化 aab 作为子序列(可以不连续)在 A 中出现的次数。 输入描述: 第一行一个仅包含 阅读全文
posted @ 2021-06-04 21:54 脂环 阅读(121) 评论(0) 推荐(0) 编辑
摘要:随便VP了一下大概是四题的样子 B. Build Roads 链接:https://ac.nowcoder.com/acm/contest/15600/B 来源:牛客网 题目描述 In the cat country, there are nnn cities. The cat country ki 阅读全文
posted @ 2021-05-13 19:54 脂环 阅读(327) 评论(0) 推荐(0) 编辑
摘要:While we enjoy chatting with friends on the internet, it is always annoying that we are overwhelmed by lots of messages in various chat groups. A grea 阅读全文
posted @ 2021-05-12 00:59 脂环 阅读(137) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示
主题色彩