2018 icpc 徐州】的更多相关文章

2018 ICPC 徐州网络赛 A. Hard to prepare 题目描述:\(n\)个数围成一个环,每个数是\(0\)~\(2^k-1\),相邻两个数的同或值不为零,问方案数. solution 将环变成链,设\(f[i][0\)~\(2]\),分别表示与第一个数相同,与第一个数不同,与第一个数相同,与第一个数的反相同.然后\(dp\)即可. 时间复杂度:\(O(n)\) B. BE, GE or NE solution 根据题目描述\(dp\)即可. 时间复杂度:\(O(nm)\) C.…
这个题,我也没想过我这样直接就过了 #include<bits/stdc++.h> using namespace std; ; typedef pair<int,int> pii; set<pii> G[maxn]; int main(){ int t,n,m,a,b,maxl; scanf("%d",&t); ;e<t;e++){ maxl=; ;i<maxn;i++)G[i].clear(); scanf("%d&…
现场赛大佬打印的代码,观摩了一哈. 写了注释,贴一下,好好学习.%%%PKU 代码: //树上差分(LCA) #include<bits/stdc++.h> #define For(i,x,y) for (int i=x;i<y;i++) #define fi first #define se second #define pb push_back #define mp make_pair #define lf else if #define dprintf(...) fprintf(s…
Day 0 上午在高铁里面,很困但是睡不着…… 中午到矿大报道. 食堂饭菜不错,有西瓜,就是有点辣. 下午热身赛,D题队友想了个假算法……GG. 评测机摸底考试正常进行. 热身赛之后精疲力尽,赶到宾馆后睡了一觉,然后晚上9点起床吃KFC,然后再睡下. Day 1 极限操作ing. 8点58分才赶到赛场,但是我好像不是很紧张的样子. 开场读题,我读到H发现是个卷积的形式,但是不会……GG 然后读了G,好像类似滑动窗口,也不会…… 这个时候zjh上去写A了,我看榜发现D有人过了,然后去读D. 哦,简…
[传送门]https://nanti.jisuanke.com/t/31458 [题目大意]有N个帧,每帧有K个动作特征,每个特征用一个向量表示(x,y).两个特征相同当且仅当他们在不同的帧中出现且向量的两个分量分别相等.求最多连续相同特征的个数? [题解]用一个map来维护帧中特征的信息,map中的键即读入的向量,因此用一个pair<int , int>表示,键的值也是一个pair,需要记录它当前已经连续了多少次,还需要记录它上一次出现的帧的位置.如果它上一帧没有出现过,那么它的连续次数就要…
A 矩阵树定理可以用于最小生成树计数,最直观的做法就是求个mst,再用矩阵树定理求最小生成树个数,但是n<=1e5,显然不是o(n^3)可以做出来的. 考虑随机数据生成器,固定1e5的边,但是边权在unsigned long long的范围内随机指定,由样例看出,即使是点数很少的情况下,最多也只有一个生成树 于是,我们猜测,只需要做一遍最小生成树,并假定不会有更多的生成树就可以了. #include<bits/stdc++.h> #define ull unsigned long lon…
2018 ICPC 沈阳网络赛 Call of Accepted 题目描述:求一个算式的最大值与最小值. solution 按普通算式计算方法做,只不过要同时记住最大值和最小值而已. Convex Hull 题目描述:定义函数\(gay(x)\),若\(x\)是某个非\(1\)的数的平方的倍数,则\(gay(x)=0\),否则\(gay(x)=x^2\),求\(\sum_{num=1}^{n} ( \sum_{i=1}^{num} gay(x) ) mod p\) solution \[\sum…
题目链接:Kattis - largesttriangle Description Given \(N\) points on a \(2\)-dimensional space, determine the area of the largest triangle that can be formed using \(3\) of those \(N\) points. If there is no triangle that can be formed, the answer is \(0\…
题目链接: 2018 ICPC Pacific Northwest Regional Contest - I-Inversions 题意 给出一个长度为\(n\)的序列,其中的数字介于0-k之间,为0表示这个位置是空的.现在可以在这些空的位置上任意填入1-k之间的数字(可以重复).问最多可以总共有多少对逆序对.(如果\(i<j,p_i>p_j\),则称\((i,j)\)是一对逆序对) \(1\leq n\leq 2*10^5,\ 1\leq k\leq 100\) 思路 第一步,先证明最优的填…
Hello everyone! I am your old friend Rikka. Welcome to Xuzhou. This is the first problem, which is a problem about the minimum spanning tree (MST). I promise you all that this should be the easiest problemeasiest problem for most people. A minimum sp…
There's a beach in the first quadrant. And from time to time, there are sea waves. A wave ( xxx , yyy ) means the wave is a rectangle whose vertexes are ( 000 , 000 ), ( xxx , 000 ), ( 000 , yyy ), ( xxx , yyy ). Every time the wave will wash out the…
2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 D Thinking-Bear magic (几何) 链接:https://ac.nowcoder.com/acm/contest/163/D来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 In order to become a magical girl, Thinking-Bear are learning m…
大致题意: 给定一个n个点m条边的图,在可以把路径上至多k条边的权值变为0的情况下,求S到T的最短路. 数据规模: N≤100000,M≤200000,K≤10 建一个立体的图,有k层,每一层是一份原图,消耗一次把一条边权值变为0的机会 = 在立体图中升一层 然后跑堆优化dij就好了,会卡spfa. AC代码: #include<cstdio> #include<queue> #include<cstring> #define rep(i,a,b) for(int i=…
题目:https://vj.69fa.cn/12703be72f729288b4cced17e2501850?v=1552995458 dp这个题目网上说是dp+离散化这个题目要对这些数字先处理然后进行dp,这个处理值得学习一下,就是把数字范围为1~1e9,转化成一个顺序列表,这个顺序列表每一个不同的位置含有不同的难度,dp[i][j]代表前面i种选出j种的方案数. #include <cstdio> #include <iostream> #include <cstdlib…
题意:四个操作,区间加,区间每个数乘,区间的数变成 2^64-1-x,求区间和. 题解:2^64-1-x=(2^64-1)-x 因为模数为2^64,-x%2^64=-1*x%2^64 由负数取模的性质可知 也就 =(2^64-1)*x%2^64 所以 2^64-1-x=2^64-1+(2^64-1)*x 所以第三个操作也就变成了区间乘 和区间加.  然后就是树剖加线段树多重标记.表示这是第一次写多重标记,整体凭感觉,细节看题解,树剖有点点遗忘,不过还好.今天看群里说邀请赛没什么价值,,细想一下那…
Press the Button Time Limit: 1 Second      Memory Limit: 131072 KB BaoBao and DreamGrid are playing a game using a strange button. This button is attached to an LED light (the light is initially off), a counter and a timer and functions as follows: W…
题目链接:https://codeforces.com/gym/102056/problem/I Warm sunshine, cool wind and a fine day, while the girl watching is pursuing in chaos. Rikka reached out her hand and got the garland on her head, finding LCR with the immortal smile. The dream ended u…
题目链接:https://codeforces.com/gym/102056/problem/L LCR is really an incredible being. Thinking so, sitting on the plane and looking at the sea, Rikka savours the fantastic journey. A fire never happened. It must be interesting to share it with her mate…
http://codeforces.com/gym/102028/problem/D 题意:根据题中给的那个图,然后题目给你 a,b,r,d,让你求出最小的满足矩形通过弯道的w 思路:…
BaoBao has just found a rooted tree with n vertices and (n-1) weighted edges in his backyard. Among the vertices, of them are red, while the others are black. The root of the tree is vertex 1 and it's a red vertex.Let's define the cost of a red verte…
n=40的01串,求有多少m=40的01串中包含它,包含的定义是存在子串有至多一个字符不相同 600组n=15的数据 15组n=40的数据,所以我们只能支持n^5的算法. 陷入两个比较有意思的坑: 1 如果手动构建fail树,建立两个并行的串,左串代表当前未使用那一个可以不相同的字符的名额,右串代表已经使用了这个名额,那么按照bfs m步的想法,左串可以通过“使用名额”到达右串,也可以通过“不使用名额”走一个fail,而右串一旦失配,只能在右串的对应位置进行fail.这样跑一遍矩阵乘法,复杂度是…
题目传送门 题号 A B C D E F G H I J K L 状态 Ο . . Ο . . Ø Ø Ø Ø . Ο Ο:当场 Ø:已补 .  :  待补 A. Edit Distance Thinking:kk pai爷 Code:kk 不能直接反转,比如"010101",直接反转后就变成"101010",右移一位,然后加个0就可以了. 所以要先统计01的数量,如果0大于1,就全变成1,1大于0,就全变成0(从数量上的改变就大于s/2了),相等的话,就看首位是0…
题意: 有一排n个石子(注意n可以为0),每次可以取1~K个连续的石子,Adrien先手,Austin后手,若谁不能取则谁输. 思路: (1) n为0时的情况进行特判,后手必胜. (2) 当k=1时,很容易可以发现:若n为偶数则后手赢,n为奇数则先手赢. (3) 当k>1时,只要先手保证这一排石子两边对称,则后手必败,所以可知k>1时先手必胜. #include<bits/stdc++.h> using namespace std; int main() { ios::sync_w…
P2 : Heshen's Account Book Time Limit:1000ms Case Time Limit:1000ms Memory Limit:512MB Description Heshen was an official of the Qing dynasty. He made a fortune which could be comparable to a whole country's wealth by corruption. So he was known as t…
P1 : Jin Yong’s Wukong Ranking List Time Limit:1000ms Case Time Limit:1000ms Memory Limit:512MB Description Jin Yong was the most famous and popular Chinese wuxia (The one who fight bad people by his Wukong i.e. Wushu and Kongfu) novelist who lived i…
Problem Description Consider a un-rooted tree T which is not the biological significance of tree or plant, but a tree as an undirected graph in graph theory with n nodes, labelled from 1 to n. If you cannot understand the concept of a tree here, plea…
There are N different kinds of transport ships on the port. The ith kind of ship can carry the weight of V[i]V[i] and the number of the ith kind of ship is 2c[i]-12^{C[i]} - 12. How many different schemes there are if you want to use these ships to t…
There are N children in kindergarten. Miss Li bought them N candies. To make the process more interesting, Miss Li comes up with the rule: All the children line up according to their student number (1...N), and each time a child is invited, Miss Li r…
Alice, a student of grade 6, is thinking about an Olympian Math problem, but she feels so despair that she cries. And her classmate, Bob, has no idea about the problem. Thus he wants you to help him. The problem is: We denote k!: k! = 1 × 2 × ⋯ × (k…