02 2025 档案
摘要:暴力做法: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int N = 10010; int n, m; bool st[N]; in
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; #define x first #define y second typedef pair<int,int> PII; const int N=5010; PII seg[N]; int main() { in
阅读全文
摘要:bool check(int date) { int year=date/10000,month=date%10000/100,day=date%100; if(day==0||month<0||month>13)return false; if(month!=2&&day>days[month])
阅读全文
摘要:输入和初始化: 读取字符串 str,并从索引 1 开始存储(C++ 中字符串索引从 0 开始,但这里为了简化计算,从 1 开始)。 n 存储字符串的长度。 数组 l[i] 存储字符 str[i] 上一次出现的位置。 数组 r[i] 存储字符 str[i] 下一次出现的位置。 数组 p 用于临时存
阅读全文
摘要:Farmer John 最近购入了 N 头新的奶牛,每头奶牛的品种是更赛牛(Guernsey)或荷斯坦牛(Holstein)之一。 奶牛目前排成一排,Farmer John 想要为每个连续不少于三头奶牛的序列拍摄一张照片。 然而,他不想拍摄这样的照片,其中只有一头牛的品种是更赛牛,或者只有一头牛的品
阅读全文
摘要:求得最少操作次数,就是逆序对数量 `#include<bits/stdc++.h> using namespace std; const int N=500010; int n;int a[N],tem[N]; long long m_sort(int l,int r) { if(l>=r)retu
阅读全文
摘要:步骤: 1.处理二维差分数组 2.利用前缀和还原棋盘状态 3.确定棋子颜色输出答案 代码: #include<bits/stdc++.h> using namespace std; const int N=2050; int n,m;int g[N][N]; int main() { cin>>n>
阅读全文
摘要:计算温度差值 首先,计算每头牛所在牛栏的理想温度 pi 和实际温度 ti 的差值 di = pi - ti,得到一个差值数组 d。我们的目标就是通过对连续区间的操作,将这个差值数组的所有元素都变为 0。 利用差分的性质 差分是一种用于记录区间变化的方法。对于一个数组 a,它的差分数组 b 满足 b[
阅读全文