![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
codeforces
题目解析和python实现
zhulf0804
点云,深度学习
展开
-
Coderforces1398C - Good Subarrays
分析一: , 对于不同的子数组∑i=lrai=r−l+1\sum_{i=l}^ra_i = r - l + 1∑i=lrai=r−l+1, 等式右边是变化的, 如何应对这种情况?令bi=ai−1,则∑i=lrbi=0b_i = a_i - 1, 则 \sum_{i=l}^rb_i = 0bi=ai−1,则∑i=lrbi=0, 问题转化成了求有多少个子数组满足其和S=0S=0S=0.分析二: 如何求有多少个子数组满足其和S=0S=0S=0?前缀和的思想, 根据前缀和的性质, 记位置..原创 2020-08-24 17:02:18 · 144 阅读 · 0 评论 -
Codeforces1382D - Unmerge
问题转化 + 0/1背包python3 代码t = int(input())for _ in range(t): n, p = int(input()), list(map(int, input().split())) v, w = [], [] i, k = 0, 0 while i < 2*n: j = i + 1 while j < 2 * n and p[j] < p[i]: j += 1原创 2020-07-23 20:27:36 · 251 阅读 · 0 评论 -
Codeforces 1097C Yuhao and a Parenthesis
python3import sysinput = sys.stdin.readlinen = int(input())v = []for _ in range(n): bkt = input() l, r, mmin = 0, 0, float('inf') for item in bkt: if item == '(': l += 1 elif item == ')': r += 1原创 2020-07-20 21:19:33 · 128 阅读 · 0 评论 -
Codeforces1096B - Substring Removal
题目思路何在?python3 代码n, s = int(input()), input()l = 0while l < n: if s[l] != s[0]: break l += 1r = n - 1while r >= 0: if s[r] != s[-1]: break r -= 1r = n - (r + 1)ans = 0if l == n: ans += (n * (n+1) // 2) %原创 2020-07-09 09:14:50 · 142 阅读 · 0 评论 -
Codeforces1088C - Ehab and a 2-operation task
两种不同的思路:n 次加法, 1次取余# pypy3n = int(input())a = list(map(int, input().split()))ans, res = 0, []flag = Falsesumm = 0for i in range(n-1, -1, -1): a[i] += summ cur = a[i] % (n + 1) if cur == i + 1: continue delta = i + 1 + (n +原创 2020-06-27 22:52:55 · 155 阅读 · 0 评论 -
Codeforces856A - Set Theory
先贴题目链接: 856A-Set Theory题目大意是给定一个数组大小为n的数组A,A中的数的范围在[1, 1e6]且各不相同,问是否存在大小为n的数组B,满足数的大小也在[1, 1e6]B中的数也各不相同A[i] + B[j] 都不相同, 对于所有的1 <= i <= n, 1 <= j <= n.思路一:a[i] + b[j] != a[x] + b[...原创 2020-04-21 00:43:04 · 206 阅读 · 0 评论