educational codeforces string round
Codeforces Round 886 (Div. 4)
Codeforces Round 886 (Div. 4) A - To My Critics 思路:最大的两个数的和大于等于10则YES #include<bits/stdc++.h> using namespace std; #define int long long typedef pair< ......
「解题报告」Codeforces Round 886 (Div. 4)
比赛地址:[Dashboard - Codeforces Round 886 (Div. 4) - Codeforces](https://codeforces.com/contest/1850) 由于时间太晚了,因此并没有参加比赛,题目都是后来补做的。 ## A. To My Critics [P ......
Codeforces 1456E - XOR-ranges
考虑一个 $L\le x\le R$ 的数 $x$,必然是一段前缀贴着 $L$ 或者 $R$,然后下一位脱离了 $L$ 和 $R$ 的限制,后面随便乱填。 注意到一个性质,对于某一位 $d$,考虑这一位上没有限制的那些位置,最优方案肯定是令其等于其左边(或者右边)第一个有限制的数的第 $d$ 位上的 ......
Codeforces Round 886 (Div. 4)
# A. To My Critics ```cpp #include using namespace std; #define int long long void solve(){ vector a(3); for( auto & i : a ) cin >> i; sort( a.begin() ......
2023.07.21 SMU Summer 2023 Contest Round 5
# 2023.07.21 [SMU Summer 2023 Contest Round 5](https://codeforces.com/group/L9GOcnr1dm/contest/459203) ## A. Points in Segments ~~~ 给n个,1~m的子集,求1~n中所有 ......
Codeforces 1329E - Dreamoon Loves AA
思考下什么样的 $l,r$ 是合法的:显然对于一组长度为 $len$ 的空隙,要使得相邻两个 A 之间的距离在 $[l,r]$ 中,你新插入的 A 的个数应该位于 $[\lceil\dfrac{len}{r}\rceil-1,\lfloor\dfrac{len}{l}\rfloor-1]$ 中。因此 ......
【周考】Round8 2024.7.21
# T1 [方差](http://222.180.160.110:1024/contest/3917/problem/1) 观察式子:$\large\sum\limits_{i=1}^{N-1} \sum\limits_{j=i+1}^{N}\left|A_{i}-A_{j}\right|^{2}= ......
Codeforces 1830E - Bully Sort
这种题肯定首先要**寻找不变量**。 显然后面排好序的后缀不会被改变。因此从整体上来看我们的流程肯定是,如果当前 $p_n=n$,就令 $n$ 减一,否则你一步换的 $i$ 肯定满足 $p_i=n$。而显然 $\min\limits_{j=i}^np_j\le i$,因此我们考察 $\sum|i-p ......
Codeforces 794G - Replace All
一个比较垃圾的做法,卡着时限过了这道题。 首先大胆猜个结论:要么 $|s|=|t|$,此时 $A,B$ 任取,要么存在字符串 $c$ 和整数 $x,y$ 使得 $A=c^x,B=c^y$,其中 $c^x$ 表示 $x$ 个 $c$ 拼接得到的结果。证明的话感觉还挺复杂的,可能要 border 引理之 ......
SMU Summer 2023 Contest Round 5
# [SMU Summer 2023 Contest Round 5](https://codeforces.com/group/L9GOcnr1dm/contest/459203) ## [A. Points in Segments](https://codeforces.com/group/L9 ......
Codeforces 1662J - Training Camp
这种数据范围和题目特点一眼网络流。 对于一种选法,我们考虑建立两个黑白矩阵,如果一个点 $(i,j)$ 被选,我们就将第 $i$ 行中 $a_{i,k}\le a_{i,j}$ 的 $(i,k)$ 在第一张网格图中染成黑色,将第 $j$ 列中 $a_{k,j}\le a_{i,j}$ 的点 $(k, ......
Codeforces Round 501 (Div. 3)
Codeforces Round 501 (Div. 3) A - Points in Segments 思路:记录每个区间 #include<bits/stdc++.h> using namespace std; #define int long long //#define int __int1 ......
Codeforces 1470F - Strange Covering
一年前模拟赛的题,时隔恰好一年零一天又考了一遍还是不会做。 对两个矩形的位置分情况: 1. 相离,此时必然存在一条与 $x$ 轴或 $y$ 轴平行的分界线,满足一个矩形在左边(下面),另一个矩形在右边(上面)。这部分显然可以 $O(n)$ 地处理。 2. 相交成十字形。这一类我的处理比较烦:考虑预处 ......
舍掉小数取整 Math.trunc(),以及 Math.floor() 、toFixed() 、Math.round()
舍掉小数取整数的时候,如果是负数,那么 Math.floor()的结果就不是我们想要的,要用Math.trunc() Math.floor()是向着更小的值取值 Math.trunc()是想着接近零的值取值 toFixed()是四舍六入,但是当保留位数的后一位是5的时候,规则太复杂 Math.rou ......
Codeforces 856F - To Play or not to Play
首先,DP 肯定是逃不掉的,因为直接贪心其实不好判断在两个人都可以上线的时间段究竟是哪个人上线,需要通过后面的情况来做出判断,但是这题值域比较大直接维护 DP 值肯定不行,因此考虑先设计一个与值域有关的 DP 然后优化。 将时间区间离散化,然后依次考虑每个时间区间。一个很自然的想法是设 $dp_{i ......
Java中String,StringBuilder, StringBuffer区别
### 1.可变性 String是不可变的字符序列:String类中使用字符数组保存字符串,因为有“final”修饰符,所以String是不可变的 ![](https://img2023.cnblogs.com/blog/3230020/202307/3230020-2023072108330906 ......
Codeforces Round div.2 C
Smiling & Weeping 我对姑娘的喜欢,何止钟意二字 题目链接:Problem - C - Codeforces 自我分析:我感觉这是一道很有意义的题目,可以帮我们更好的理解二进制的本质 思路:首先先了解一下题目,我们是求由第i个数到末尾的异或和(异或:相同为0,不同为1),那么我们可以 ......
Codeforces 1787I - Treasure Hunt
注意到这什么 $s>q$ 或 $t\le q$ 的限制条件是没有用的,因为如果 $s\le q>1;solve2(l,mid);solve2(mid+1,r); static ll mn[MAXN+5],mx[MAXN+5],f[MAXN+5],g[MAXN+5]; mn[mid+1]=mx[mid ......
Codeforces Round 882 div.2 B
Smiling & Weeping 玫瑰花你拿才好看,风景要和你看才浪漫--<-<-<@ B. Hamon Odyssey time limit per test 1 second memory limit per test 256 megabytes input standard input ou ......
String数组split方法常出现数组越界
String str = "a,b,c,,"; String[] ary = str.split(","); System.out.println(ary.length) ;// 结果是3而不是4 注意防止数组越界 ......
Raw String Literals
Raw string literals are string literals that can span multiple lines of code, they don’t require escaping of embedded double quotes, and escape sequen ......
Codeforces 1696G - Fishingprince Plays With Array Again
初读题目可以发现一些性质: - 每次操作会使整个序列的和减少至多 $X+Y$,因此 $ans\ge\dfrac{\sum a_i}{X+Y}$。 - 对于两个不相邻位置 $a_i,a_j(|i-j|>1)$,每次操作最多使它们的和减少 $\max(X,Y)$。 然后你发现两个限制可以结合在一起使用, ......
strings
strings 在对象文件或二进制文件中查找可打印的字符串 ## 补充说明 **strings命令** 在对象文件或二进制文件中查找可打印的字符串。字符串是4个或更多可打印字符的任意序列,以换行符或空字符结束。 strings命令对识别随机对象文件很有用。 ### 语法 ```shell strin ......
Codeforces 1446F - Line Distance
[感觉这种类似于让你找第 $k$ 大距离的计算几何题其实都挺套路的。](https://www.cnblogs.com/tzcwk/p/Codeforces-607E.html) 二分一个答案 $t$,然后思考一下什么样的点对满足原点到它们的连线的距离 $\le t$。以原点为圆心 $t$ 为半径画 ......
Codeforces 1621H - Trains and Airplanes
这能 3500? 对于一组在 $u$ 上的询问,考虑每种线路 $x$,假设 $1\to u$ 路径上线路 $x$ 的长度为 $len$,那么不难发现收罚款的次数只有两种可能:$\lfloor\dfrac{len}{T}\rfloor$ 或者 $\lfloor\dfrac{len}{T}\rfloor ......
Codeforces 1785E - Infinite Game
很没感觉的一道题。 首先特判掉 $n\le 2$。 在 $s$ 无穷拼接的过程中,我们考虑一个周期一个周期地匹配,由于每局比赛的长度是 $2$ 或者 $3$,因此每个周期开始的时候,把上个周期剩下的零头匹配完之后起始匹配位置只可能是 $0$ 或 $1$ 或 $2$,并且对于一个起始匹配位置 $i(0 ......
Educational Codeforces Round 151
### AB 略 ### C(简) 将密码 $P$ 与 $S$ 进行匹配,按顺序决定 $P_i$,为了避免 $P$ 成为 $S$ 的子串,每次贪心地选择当前匹配位置最靠后的。若出现匹配不上则“YES”。 ### D 有点意思。从基础的情况入手: 设 $\{s_i\}$ 为 $\{a_i\}$ 的前缀 ......
[LeetCode] 2486. Append Characters to String to Make Subsequence
You are given two strings s and t consisting of only lowercase English letters. Return the minimum number of characters that need to be appended to th ......
Codeforces Round 882 div.2 A
Smiling&Weeping 总有人间一两风,填我十万八千梦 A. The Man who became a God time limit per test 1 second memory limit per test 256 megabytes input standard input outp ......
Codeforces Round 885 (Div. 2)
# Preface 打的就是依托答辩居然也能上分,看来手稳还是重要的说 D题半场开香槟以为随便写,然后没想到怎么处理这个局部没有三分性的函数,直接GG 后面听学长一说其实分成四种函数分别求最值即可直接恍然大悟,只能说还是太菜太菜 而且F好像是个蓝桥杯的某个题的弱化版,我说比赛的时候怎么那么多人艹过去 ......