second 140e abc sum

ABC311E 题解

看到官方题解是 $O(n^2)$ 的 dp。 提供一个 $O(n^2 \log_2 n)$ 的做法,考场思路,大概比较简单。 ## Description 给一个 $H$ 行 $W$ 列的网格,其中一些点被涂成黑色,求整个正方形内都未被涂黑的正方形的个数。 ## Solution 考场上首先想到的简 ......
题解 311E ABC 311

3-3 编写函数 expand(s1, s2),将字符串 s1 中类似于 a-z 一类的速记符号 在字符串 s2 中扩展为等价的完整列表 abc…xyz。该函数可以处理大小写字母和数字,并可 以处理 a-b-c、a-z0-9 与-a-z 等类似的情况

# Archlinux GCC 13.1.1 20230429 2023-08-01 17:03:12 星期二 点击查看代码 ``` #include void expand( const char *s1, char *s2 ) { int i, j, k; i = j = k = 0; whil ......
字符串 函数 字符 a-z 等价

[LeetCode] 712. Minimum ASCII Delete Sum for Two Strings

Given two strings s1 and s2, return the lowest ASCII sum of deleted characters to make two strings equal. Example 1: Input: s1 = "sea", s2 = "eat" Out ......
LeetCode Minimum Strings Delete ASCII

[ABC311Ex] Many Illumination Plans

银牌题,zlt差点ak。 发现我们只关注保留下来的结点,每个保留的结点的父亲是他祖先中第一个保留的结点,则数颜色不同的条件相当于新树相邻结点颜色不同。 考虑dp,设 $dp_{u,X,0/1}$ 表示 $u$ 子树内最上方的结点颜色为 $0/1$,树的总重量为 $X$ 的最大价值。每次转移就是暴力做 ......
Illumination Plans Many ABC 311

leetcode-n-sum总结

总结一下leetcode中遇见的2-sum, 3-sum, 4-sum问题,并扩展到n-sum。 1. 两数之和 - 力扣(LeetCode) 梦开始的地方,不多说。 class Solution { public int[] twoSum(int[] nums, int target) { Map ......
leetcode-n-sum leetcode sum

[UNIQUE VISION Programming Contest 2023 Summer(AtCoder Beginner Contest 312) - AtCoder](https://atcoder.jp/contests/abc312)

# [UNIQUE VISION Programming Contest 2023 Summer(AtCoder Beginner Contest 312) - AtCoder](https://atcoder.jp/contests/abc312) ## [A - Chord (atcoder.j ......
Contest AtCoder Programming 312 Beginner

【题解】[ABC312E] Tangency of Cuboids(adhoc)

# 【题解】[ABC312E] Tangency of Cuboids 少见的 at 评分 $2000+$ 的 ABC E 题,非常巧妙的一道题。 特别鸣谢:@[dbxxx](https://www.luogu.com.cn/user/120868) 给我讲解了他的完整思路。 ## 题目链接 [AB ......
题解 Tangency Cuboids adhoc 312E

[ABC312] 题解 [D~Ex]

# [ABC312] 题解 [D~Ex] ## **D - Count Bracket Sequences** 一个括号序列 $s$ 包含 `(, ), ?`,`?` 可以填任意括号,问你填完后有多少种合法序列方式。 这是一个 Classical 的 括号序列 DP,使用这个状态表示可以解决很多括号 ......
题解 ABC 312 Ex

【题解】[ABC312G] Avoid Straight Line(容斥,树上统计,dfs)

# 【题解】[ABC312G] Avoid Straight Line ## 题目链接 [[ABC312G] Avoid Straight Line](https://atcoder.jp/contests/abc312/tasks/abc312_g) ## 题意概述 给定一棵 $n$ 个节点的树, ......
题解 Straight Avoid 312G Line

abc312e <暴力>

### 题目 [E - Tangency of Cuboids](https://atcoder.jp/contests/abc312/tasks/abc312_e) ### 思路 意识到本题的数据规模可以暴力去做! - $N=100$,$N^3$直接遍历整个空间可做; - 立方体间不相交,也就是可 ......
暴力 312e abc 312 lt

abc312d <dp, 括号匹配方案数>

### 题目 [D - Count Bracket Sequences](https://atcoder.jp/contests/abc312/tasks/abc312_d) ### 思路 - `dp[i][j]`为考虑前$i$个位置,待匹配的`(`有$j$个的方案数; ### 代码 点击查看代码 ......
括号 方案 312d abc 312

abc312c <二分答案>

### 题目 [C - Invisible Hand](https://atcoder.jp/contests/abc312/tasks/abc312_c) ### 思路 - 二分X,同时二分得到buyer和seller的人数(很精巧的二分~); - 当然,从复杂度角度,$O(N\log N)$ 也 ......
答案 312c abc 312 lt

ABC312

## T1:[Chord](https://atcoder.jp/contests/abc312/tasks/abc312_a "Chord") 模拟 代码实现 ``` s = input() if s in 'ACE, BDF, CEG, DFA, EGB, FAC, GBD': print('Y ......
ABC 312

ABC308

## T1:[New Scheme](https://atcoder.jp/contests/abc308/tasks/abc308_a "New Scheme") 模拟 代码实现 ``` def solve(): s = list(map(int, input().split())) for i ......
ABC 308

mysql sum 大量数据查询慢的加速的一种处理方法

有时候查一个月数据,要用到sum来统计,数据大的话,查询起来那一个是慢,可以考虑用联合查询 1.建视图,把一个月要查的分成三段,然后做成一个视图再查 CREATE VIEW B4SUM202302 AS SELECT * FROM (SELECT a,b FROM ( SELECT SUM(B4)A ......
数据查询 方法 数据 mysql sum

[ABC296E] Transition Game

题意:给定$n$个数,$a_i$为$i$的后继,有$n$轮游戏中,若第$i$轮游戏,对于$1~n$中任意一个后继次数$j$,都能选择一个数$x$使得$x$后继$j$次之后都为$i$,则称之赢一局,问赢的局数。 首先可以肯定一个数的后继是唯一确定的,我们可以从任意$1~n$中的连向它的后继。考虑如果当 ......
Transition 296E Game ABC 296

Atcoder ABC259H Yet Another Path Counting

首先可以想到有组合数的方法: 令起点为 $(x1, y1)$,终点为 $(x2, y2)$,则路径方案数就为 $\binom{x2 + y2 - x1 - y1}{x2 - x1}$,这样设有 $k$ 个相同颜色的点,时间复杂度就为 $O(k^2)$。 再考虑到还有 $\text{DP}$ 方法: ......
Counting Atcoder Another 259H Path

AT_abc182_d 题解

[洛谷链接](https://www.luogu.com.cn/problem/AT_abc182_d)&[Atcoder 链接](https://www.luogu.com.cn/remoteJudgeRedirect/atcoder/abc182_d) 本篇题解为此题**较简单做法**及**较少 ......
题解 AT_abc 182 abc AT

Atcoder ARC060D Digit Sum

看到 $n\le 10^{11}$,考虑按根号分为两部分处理。 对于 $b\le \sqrt{n}$,考虑直接暴力算 $\operatorname{f}(b, n)$ 判断是否等于 $s$,这部分的计算量是 $O(\sqrt{n})$ 级别的。 对于 $\sqrt{n} n$,这个时候 $\oper ......
Atcoder Digit 060D ARC 060

[ABC308G] Minimum Xor Pair Query 题解

[Minimum Xor Pair Query](https://www.luogu.com.cn/problem/AT_abc308_g) ### 题目大意 维护一个序列,支持动态插入,删除,查询最小异或对。 ### 思路分析 看到查询最小异或对首先想到 01Trie,但 01Trie 不支持删除 ......
题解 Minimum Query 308G Pair

AT_abc178_d 题解

[洛谷链接](https://www.luogu.com.cn/problem/AT_abc178_d)&[Atcoder 链接](https://www.luogu.com.cn/remoteJudgeRedirect/atcoder/abc178_d) 本篇题解为此题较**简单做法**及**较少 ......
题解 AT_abc 178 abc AT

1775.equal sum arrays with minimum number of operations

Description 1775.equal-sum-arrays-with-minmum-number-of-operations Solution hash table + greedy algorithm The general idea of this problem is hash + g ......
operations minimum arrays number equal

[ABC308G]MinimumXorPairQuery

# [[ABC308G] Minimum Xor Pair Query](https://www.luogu.com.cn/problem/AT_abc308_g) 必须知道的性质: > 对于三个非负整数 $x,y,z(x < y < z)$,有 $\min(x \bigoplus y,y\bigo ......
MinimumXorPairQuery 308G ABC 308

[ABC267F] Exactly K Steps题解

### [ABC267F] Exactly K Steps ### 题意 有一颗 $n$ 个点,$n - 1$ 条边的树,找到任意一个离结点 $u$ 的距离恰好为 $k$ 的点,或报告无解。 定义两点 $u, v$ 间的距离为这两个点之间的最短路径所包含的边数。 ### 思路 考虑无解,显然如果从 ......
题解 Exactly Steps 267F ABC

[ARC150F] Constant Sum Subsequence

Problem StatementWe have a sequence of positive integers of length $N^2$, $A=(A_1,\ A_2,\ \dots,\ A_{N^2})$, and a positive integer $S$. For this sequ ......
Subsequence Constant 150F ARC 150

[ABC311G] One More Grid Task

Problem StatementThere is an $N \times M$ grid, where the square at the $i$-th row from the top and $j$-th column from the left has a non-negative int ......
311G More Grid Task ABC

[ABC309G] Ban Permutation

Problem StatementFind the number, modulo $998244353$, of permutations $P=(P_1,P_2,\dots,P_N)$ of $(1,2,\dots,N)$ such that: $|P_i - i| \ge X$ for all ......
Permutation 309G ABC 309 Ban

[ABC311G] One More Grid Task

# [ABC311G] One More Grid Task ## 题意 给一个矩阵,定义一个矩阵的价值为其最小值乘上总和,问子矩阵中最大价值。 ## 题解 感觉有些简单,不配在G这个位置。 观察贡献的形式,我们需要维护最小值与还有和。 首先第一个想法是以最小值为分治点来分治,划分区域。 但是对比一 ......
311G More Grid Task ABC

openpyxl模块---------------------------求和sum

准备数据: 求和代码: import openpyxlwb = openpyxl.load_workbook('C:/Users/Administrator/Desktop/1.xlsx')ws = wb['test']min_row = ws.min_rowmax_row = ws.max_row ......
模块 openpyxl sum

918. Maximum Sum Circular Subarray (Medium)

Description 918. Maximum Sum Circular Subarray (Medium) Given a circular integer array nums of length n, return the maximum possible sum of a non-empt ......
Circular Subarray Maximum Medium 918