atcoder-abc medicine atcoder abc
[ABC312] 题解 [D~Ex]
# [ABC312] 题解 [D~Ex] ## **D - Count Bracket Sequences** 一个括号序列 $s$ 包含 `(, ), ?`,`?` 可以填任意括号,问你填完后有多少种合法序列方式。 这是一个 Classical 的 括号序列 DP,使用这个状态表示可以解决很多括号 ......
[ARC119F] AtCoder Express 3
有简单做法,但是pb大神讲了自动机做法。 这么有趣的自动机不去做?亏大发。 有两个重要的观察。 当你出现长度大于 $4$ 的连续段时,一定会向后走一次并跳过这一段。 某些时候,当你能用同样的步数走到最后的两个格子,且中一个是 $\rm A$,一个是 $B$ 时,可以看作你处于一个既能是 $\rm A ......
【题解】[ABC312G] Avoid Straight Line(容斥,树上统计,dfs)
# 【题解】[ABC312G] Avoid Straight Line ## 题目链接 [[ABC312G] Avoid Straight Line](https://atcoder.jp/contests/abc312/tasks/abc312_g) ## 题意概述 给定一棵 $n$ 个节点的树, ......
Atcoder-Beginner-Contest-312 A~Ex
# [$Atcoder-Beginner-Contest-312$](https://atcoder.jp/contests/abc312/) AB过于简单,在此略去。 ## [$C-Invisible$ $Hand$](https://atcoder.jp/contests/abc312/task ......
abc312e <暴力>
### 题目 [E - Tangency of Cuboids](https://atcoder.jp/contests/abc312/tasks/abc312_e) ### 思路 意识到本题的数据规模可以暴力去做! - $N=100$,$N^3$直接遍历整个空间可做; - 立方体间不相交,也就是可 ......
abc312d <dp, 括号匹配方案数>
### 题目 [D - Count Bracket Sequences](https://atcoder.jp/contests/abc312/tasks/abc312_d) ### 思路 - `dp[i][j]`为考虑前$i$个位置,待匹配的`(`有$j$个的方案数; ### 代码 点击查看代码 ......
abc312c <二分答案>
### 题目 [C - Invisible Hand](https://atcoder.jp/contests/abc312/tasks/abc312_c) ### 思路 - 二分X,同时二分得到buyer和seller的人数(很精巧的二分~); - 当然,从复杂度角度,$O(N\log N)$ 也 ......
AtCoder Beginner Contest 312
## [A - Chord (abc312 A)](https://atcoder.jp/contests/abc312/tasks/abc312_a) ### 题目大意 给定一个长度为$3$的字符串,问是不是`ACE, BDF, CEG, DFA, EGB, FAC, GBD`中的一个。 ### ......
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 ......
(AtCoder Beginner Contest 312)
(AtCoder Beginner Contest 312) A - Chord #include<bits/stdc++.h> using namespace std; #define int long long //#define int __int128 typedef pair<int,in ......
ABC308
## T1:[New Scheme](https://atcoder.jp/contests/abc308/tasks/abc308_a "New Scheme") 模拟 代码实现 ``` def solve(): s = list(map(int, input().split())) for i ......
[ABC296E] Transition Game
题意:给定$n$个数,$a_i$为$i$的后继,有$n$轮游戏中,若第$i$轮游戏,对于$1~n$中任意一个后继次数$j$,都能选择一个数$x$使得$x$后继$j$次之后都为$i$,则称之赢一局,问赢的局数。 首先可以肯定一个数的后继是唯一确定的,我们可以从任意$1~n$中的连向它的后继。考虑如果当 ......
Atcoder ABC259H Yet Another Path Counting
首先可以想到有组合数的方法: 令起点为 $(x1, y1)$,终点为 $(x2, y2)$,则路径方案数就为 $\binom{x2 + y2 - x1 - y1}{x2 - x1}$,这样设有 $k$ 个相同颜色的点,时间复杂度就为 $O(k^2)$。 再考虑到还有 $\text{DP}$ 方法: ......
AT_abc182_d 题解
[洛谷链接](https://www.luogu.com.cn/problem/AT_abc182_d)&[Atcoder 链接](https://www.luogu.com.cn/remoteJudgeRedirect/atcoder/abc182_d) 本篇题解为此题**较简单做法**及**较少 ......
Atcoder ARC060D Digit Sum
看到 $n\le 10^{11}$,考虑按根号分为两部分处理。 对于 $b\le \sqrt{n}$,考虑直接暴力算 $\operatorname{f}(b, n)$ 判断是否等于 $s$,这部分的计算量是 $O(\sqrt{n})$ 级别的。 对于 $\sqrt{n} n$,这个时候 $\oper ......
[ABC308G] Minimum Xor Pair Query 题解
[Minimum Xor Pair Query](https://www.luogu.com.cn/problem/AT_abc308_g) ### 题目大意 维护一个序列,支持动态插入,删除,查询最小异或对。 ### 思路分析 看到查询最小异或对首先想到 01Trie,但 01Trie 不支持删除 ......
AT_abc178_d 题解
[洛谷链接](https://www.luogu.com.cn/problem/AT_abc178_d)&[Atcoder 链接](https://www.luogu.com.cn/remoteJudgeRedirect/atcoder/abc178_d) 本篇题解为此题较**简单做法**及**较少 ......
[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 ......
[ABC267F] Exactly K Steps题解
### [ABC267F] Exactly K Steps ### 题意 有一颗 $n$ 个点,$n - 1$ 条边的树,找到任意一个离结点 $u$ 的距离恰好为 $k$ 的点,或报告无解。 定义两点 $u, v$ 间的距离为这两个点之间的最短路径所包含的边数。 ### 思路 考虑无解,显然如果从 ......
[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 ......
[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 ......
[ABC311G] One More Grid Task
# [ABC311G] One More Grid Task ## 题意 给一个矩阵,定义一个矩阵的价值为其最小值乘上总和,问子矩阵中最大价值。 ## 题解 感觉有些简单,不配在G这个位置。 观察贡献的形式,我们需要维护最小值与还有和。 首先第一个想法是以最小值为分治点来分治,划分区域。 但是对比一 ......
AtCoder Beginner Contest 311
AtCoder Beginner Contest 311 First ABC 思路:找到第一个a,b,c都出现的位置 #include<bits/stdc++.h> using namespace std; #define int long long //#define int __int128 t ......
AtCoder Beginner Contest 311
# A - First ABC ```cpp #include using namespace std; #define int long long int32_t main() { ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nu ......
AtCoder Grand Contest 040 E Prefix Suffix Addition
[洛谷传送门](https://www.luogu.com.cn/problem/AT_agc040_e "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/agc040/tasks/agc040_e "AtCoder 传送门") 比较神奇的题。 考 ......
AT_abc246_d 题解
[洛谷链接](https://www.luogu.com.cn/problem/AT_abc246_d)&[Atcoder 链接](https://atcoder.jp/contests/abc246/tasks/abc246_d) 本篇题解为此题较**简单做法**及**较少码量**,并且码风优良, ......
AT_abc218_d 题解
[洛谷链接](https://www.luogu.com.cn/problem/AT_abc218_d)&[Atcoder](https://atcoder.jp/contests/abc218/tasks/abc218_d) 本篇题解为此题较**简单做法**及**较少码量**,并且码风优良,请放心 ......
AT_abc215_d 题解
[洛谷链接](https://www.luogu.com.cn/problem/AT_abc215_d)&[Atcoder 链接](https://atcoder.jp/contests/abc215/tasks/abc215_d) 本篇题解为此题较**简单做法**及**较少码量**,并且码风优良, ......
Solution to AT_abc285_g Tatami
### Statement 请用若干个 $1 \times 1$ 和 $1 \times 2$ 的瓷砖(可以旋转)不重叠地完全覆盖 $H \times W$ 的长方形网格。第 $i$ 行第 $j$ 列的网格有字符 $c_{i,j}$,含义如下: - `1`:该网格只能用 $1 \times 1$ 的 ......