摘要: #include<iostream> #include<vector> #include<functional> #include<cmath> #include<queue> #include<map> #include<string> #include<set> #define int long 阅读全文
posted @ 2025-07-10 23:51 shen_kong 阅读(22) 评论(0) 推荐(0)
摘要: 给定一个长度为n的整数数组,问有多少对互不重叠的非空区间,使得两个区间内的数的异或和为0。 暴力,每次找一个中点,找左右两边异或值一样的区间 #include<bits/stdc++.h> #define int long long #define TEST #define TESTS int _; 阅读全文
posted @ 2025-01-16 12:57 shen_kong 阅读(15) 评论(0) 推荐(0)
摘要: 给定数组, 将数组分为尽可能少的段使得每一个段的第一个或最后一个数字是段的长度, 求最少的段数 线性dp 令 dp[i] 表示将前 i 个数字全部分好段最少的段数 dp[0] = 0 枚举每一个 a[i], 这个数字有两种分段方案: 作为某个段的结尾: dp[i] = min(dp[i], dp[i 阅读全文
posted @ 2025-01-04 18:58 shen_kong 阅读(45) 评论(0) 推荐(0)
摘要: 给一 n 个数字的数组, 一个翻转操作将一个数按二进制形式翻转再转回十进制. 问最多翻转 m 个连续段, 完成后数组和最大为多少. 先求贡献数组(翻转后能增加多少), 然后问题转化为数组中选 m 个段和最大, 这和最大连续子数组和是不同的(只有一个段). 定义 \(dp[i][j][0] 代表在递推 阅读全文
posted @ 2025-01-04 17:17 shen_kong 阅读(106) 评论(0) 推荐(0)
摘要: You are preparing a ribbon to decorate the Christmas present box. You plan to dye the ribbon, initially white, to make a stripe pattern of different s 阅读全文
posted @ 2025-01-04 01:33 shen_kong 阅读(64) 评论(0) 推荐(0)
摘要: Wave is given five integers \(k\), \(l_1\), \(r_1\), \(l_2\), and \(r_2\). Wave wants you to help her count the number of ordered pairs \((x, y)\) suc 阅读全文
posted @ 2024-12-16 12:41 shen_kong 阅读(135) 评论(0) 推荐(0)
摘要: In the fourth labor of Rostam, the legendary hero from the Shahnameh, an old witch has created a magical maze to trap him. The maze is a rectangular g 阅读全文
posted @ 2024-12-10 01:32 shen_kong 阅读(61) 评论(0) 推荐(0)
摘要: 补码的本质就是用模运算代替负数 阅读全文
posted @ 2024-12-09 16:56 shen_kong 阅读(15) 评论(0) 推荐(0)
摘要: Suppose you are working in some audio streaming service. The service has \(n\) active users and \(10^9\) tracks users can listen to. Users can like tr 阅读全文
posted @ 2024-12-04 18:50 shen_kong 阅读(58) 评论(0) 推荐(0)
摘要: Slavic has an array of length \(n\) consisting only of zeroes and ones. In one operation, he removes either the first or the last element of the array 阅读全文
posted @ 2024-12-03 17:28 shen_kong 阅读(29) 评论(0) 推荐(0)