为了做分治,用 vector 或者结构体包一个 vector 来存多项式(系数)。 写完后又 WA, T 了几次,找出几个写错的地方:vector 数组下标从 0 开始,容斥取模要注意负数,因为用 vector 存多项式系数所以注意调用的时候不要下标超限。然后还是一直 WA 第 15 个点,对拍也拍不出错,一晚上没调出来心力交瘁。但是后来做...
L. Perfect Matchings 标签:容斥原理,树形DPDP 如果没有删边的限制就是组合数直接算,但是有一些边是不能选的. 不妨考虑利用容斥原理来做,钦定选上ii条树边,然后扣掉点后剩下的边随便选. 然后这个就符合二项式反演中的公式,直接反演就能求出g[i]g[i]. 这里恰好i=0i=0, 所以直接上容斥的公式即可,时间复杂...
int ah[N]; int bh[N]; int at[N], atc[N]; int bt[N], btc[N]; int n, m; double as, bs, cnt; void dfs(int huihe, int o, double s) { int flagn = 0, flagm = 0; for(int i = 1; i <= n; i++) { if(ah[i] > 0) { flagn++; } } for(int i = 1; i ...
The 2021 ICPC Asia Regionals Online Contest (I) G Longest Prefix Matching (trie),题意:给你$n$个ip地址,以及长度和它所对应的nextip地址,有$m$个询问,在$n$个给定的ip地址中找到公共前缀大于所给长度并且最长的对应ip地址。(疯狂口胡)题解:每个ip地址有四个数
The 2021 ICPC Asia Nanjing Regional Contest E.Paimon Segment Tree 区间合并线段树/维护矩阵乘法 题目大意 给定长度为 的序列 ,要求支持区间加操作,同时对操作记录历史版本,查询问区间 操作 中的每个数的平方之和。 题目思路 推了一会,发现线段树合并硬写很凌乱,然后队友告诉是线段树维护矩阵乘法,那么就考虑怎么维护...
VP :The 2024 ICPC Asia Nanjing Regional Contest (The 3rd Universal Cup. Stage 16: Nanjing) B. Birthday Gift 联想到之前一场比赛的签到题的结论: 给定一组插入若干个2的01串,相邻不相同可以消去,2可以变成0或1,问最后能剩下的串最短长度,结论是最短长度 = MAX(|0的个数 - 1的个数| - 2的个...
// https://ac.nowcoder.com/acm/contest/32708/E #include "stdafx.h" #include <algorithm> #include <iostream> #include <cstring> using namespace std; const int N = 1E5 + 100; int n, m, block; int arr[N]={ 0,1, 2, 3,4, 1,2,3 ...
Just a few hours ago, The 2021 ICPC Asia Regionals Online Contest (I) was held onhttps://pintia.cn/. This contest(and the next on 26th) will determine the WHOLE Asia-East Division‘s quota. And how fantastic(according to some coaches) of these problems in this online contest? I uploa...
Hello! I'm happy to announce The 2nd Universal Cup. Stage 11: Nanjing, which will be held on November 25th, 2023. This contest is an official ICPC Regional Contest — The 2023 ICPC Asia Nanjing Regional Contest. The contest is prepared by theSUA Programming Contest Problem Setter Team, whi...
我们发现我们可以用前缀和计算1 - i的区间贡献,我们单循环扫一遍即可。但是一个左右端点都不确定的区间的贡献是不是s[r] - s[l - 1]呢?显然因为有环的存在,是不对的。加入有这样一个区间111000111,其实实际上有6个1连续,贡献为3,但是我们可能会把贡献算成2 + 2。因此不对的,差分算区间一定要保证两端都...