09 2022 档案
摘要:Problem Description ACM-DIY is a large QQ group where many excellent acmers get together. It is so harmonious that just like a ...
阅读全文
摘要:Problem Description Recently, scientists find that there is love between any of two people. For example, between A and B, if A ...
阅读全文
摘要:Problem Description The system of Martians' blood relations is confusing enough. Actually, Martians bud when they want and wher...
阅读全文
摘要:Problem Description 有N个比赛队(1#include#include#include#include#include#include#include#include#include#include#include#include#de...
阅读全文
摘要:Problem Description Order is an important concept in mathematics and in computer science. For example, Zorn's Lemma states: ``a...
阅读全文
摘要:Problem Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed share...
阅读全文
摘要:Problem Description Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer...
阅读全文
摘要:Problem Description 某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。 现在,已知起点和...
阅读全文
摘要:Problem Description Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip...
阅读全文
摘要:Problem Description Bajtek, known for his unusual gifts, recently got an integer array x0,x1,…,xk−1. Unfortunately, after a hu...
阅读全文
摘要:原计划的图的遍历和拓扑排序看完了,顺便把 Floyd 和 Dijkstra 看完了,这周计划是 Ford、SPFA、并查集以及 2-SAT 问题 学长学姐去 ICPC 拿了块牌回来,羡慕 自己队出去比赛的次数是 17 级里最多的,但一直打铁一直让教练失望,还是...
阅读全文
摘要:Problem Description There are m people in n cities, and they all want to attend the party which hold by zz. They set out at the...
阅读全文
摘要:Problem Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two...
阅读全文
摘要:Problem Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representat...
阅读全文
摘要:Problem Description 1967年,美国著名的社会学家斯坦利·米尔格兰姆提出了一个名为“小世界现象(small world phenomenon)”的著名假说,大意是说,任何2个素不相识的人中间最多只隔着6个人,即只用6个人就可以将他们联...
阅读全文
摘要:这周的计划是 Ford、SPFA 看完了,2-SAT 看了一半,并查集没按计划完成,但把最小生成树看了,还算可以。。。 下周 2-SAT、次短路径、并查集。。。 今晚打比赛。。菜的一批。。。做了 4、5 遍的红与黑 WA 了好几次,翻过来覆过去的找错。。。最后...
阅读全文
摘要:【概述】 并查集(Union-Find Set)是一种用于分离集合操作的抽象数据类型,其处理的是集合(set)之间的关系,一般处理的是图的连通分量,当给出两个的元素的一个无序对 (a,b) 时,需要快速合并(union) a 和 b 所在的集合,这期间需要反复...
阅读全文
摘要:Problem Description Farmer John and Betsy are playing a game with N (1 #include#include#include#include#include#include#include...
阅读全文
摘要:Problem Description 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N...
阅读全文
摘要:Problem Description The zoo have N cats and M dogs, today there are P children visiting the zoo, each child has a like-animal a...
阅读全文
摘要:Problem Description In the second year of the university somebody started a study on the romantic relations between the student...
阅读全文
摘要:Problem Description Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 ...
阅读全文
摘要:Problem Description Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fa...
阅读全文
摘要:Problem Description On Octorber 21st, HDU 50-year-celebration, 50-color balloons floating around the campus, it's so nice, isn'...
阅读全文
摘要:Problem Description Frank N. Stein is a very conservative high-school teacher. He wants to take some of his students on an excu...
阅读全文
摘要:Problem Description In a kindergarten, there are a lot of kids. All girls of the kids know each other and all boys also know ea...
阅读全文
摘要:并查集、2-SAT、二分图相关内容都看完了,但只做了些并查集、二分图判定、二分图最大匹配的题,其他内容仍需多做些题来验证一下,只剩差分约束和网络流内容没看,考试周快来了,这周先尽量看吧。。 天冷了,这周一天到晚窝在宿舍,基本废了,欠下的东西太多了,今天把东西搬...
阅读全文
摘要:Problem Description Jimmy is studying Advanced Graph Algorithms at his university. His most recent assignment is to find a maxi...
阅读全文
摘要:Problem Description 小希和Gardon在玩一个游戏:对一个N*M的棋盘,在格子里放尽量多的一些国际象棋里面的“车”,并且使得他们不能互相攻击,这当然很简单,但是Gardon限制了只有某些格子才可以放,小希还是很轻松的解决了这个问题(见...
阅读全文
摘要:Problem Description There are a group of students. Some of them may know each other, while others don't. For example, A and B k...
阅读全文
摘要:Problem Description RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了。可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做partner和她同坐。但是,每个女孩都有各自的想法...
阅读全文
摘要:Problem Description The gopher family, having averted the canine threat, must face a new predator. The are n gophers and m go...
阅读全文
摘要:Problem Description It is well known that it is not easy to select courses in the college, for there is usually conflict among ...
阅读全文
摘要:Problem Description Farmer John completed his new barn just last week, complete with all the latest milking technology. Unfortu...
阅读全文
摘要:Problem Description Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your ...
阅读全文
摘要:Problem Description A thief is running away! We can consider the city where he locates as an undirected graph in which nodes st...
阅读全文
摘要:Problem Description Now and then you play the following game with your friend. Your friend writes down a sequence consisting of...
阅读全文
摘要:Problem Description N children are playing Rochambeau (scissors-rock-cloth) game with you. One of them is the judge. The rest c...
阅读全文
摘要:Problem Description Fibsieve had a fantabulous (yes, it's an actual word) birthday party this year. He had so many gifts that h...
阅读全文
摘要:【基本概念】 哈密尔顿通路:经过图中每个结点且仅经过一次的通路。哈密尔顿回路:经过图中每个结点且仅经过一次的回路。哈密尔顿图:存在哈密尔顿回路的图。竞赛图:每对顶点之间都有一条边相连的有向图,n 个顶点的竞赛图称为 n 阶竞赛图。与欧拉回路的对比:欧拉回路是指...
阅读全文
摘要:【基本概念】 欧拉通路:通过图中所有边一次且仅一次行遍所有顶点的通路欧拉回路:通过图中所有边一次且仅一次行遍所有顶点的回路欧拉图:具有欧拉回路的图半欧拉图:具有欧拉通路而无欧拉回路的图奇度点:与点相连的边的数目为奇数的点偶度点:与点相连的边的数目为偶数的点【欧...
阅读全文
摘要:Problem Description Given an array with n integers, and you are given two indices i and j (i ≠ j) in the array. You have to fin...
阅读全文
摘要:【概述】 图的遍历问题是从图中某一顶点出发,系统地访问图中所有顶点,使每个顶点恰好被访问一次。 目前,图的遍历问题分为四类: 欧拉通路与欧拉回路问题:遍历完所有的边而不能有重复,即一笔画问题中国邮递员问题:遍历完所有的边而可以有重复哈密尔顿问题:遍历完所有的顶...
阅读全文
摘要:Problem Description Dr. Mob has just discovered a Deathly Bacteria. He named it RC-01. RC-01 has a very strange reproduction sy...
阅读全文
摘要:Problem Description dxy has a collection of a series of books called "The Stories of SDOI",There are n(n≤19) books in this seri...
阅读全文
摘要:Problem Description In the year of 200, two generals whose names are Cao Cao and Shao Yuan are fighting in Guandu. The battle o...
阅读全文
摘要:昨天回去发高烧了,睡了一上午还是烧,下午去打了个退烧针,回实验室补了几道题就回宿舍睡觉了,这几天由于身体状态不是很好,效率低的吓人,希望赶紧好起来吧 下午补的几道题都是图论的,图论的题虽说有模版,但难点一是建图,二是根据题设进行优化,很多题就是告诉你是哪个模版...
阅读全文
摘要:Problem Description Kids in kindergarten enjoy playing a game called Hawk-and-Chicken. But there always exists a big problem: e...
阅读全文
摘要:Problem Description There is a path graph G=(V,E) with nn vertices. Vertices are numbered from 1 to n and there is an edge with...
阅读全文
摘要:【概念】 整式方程就是方程中所有的未知数均在分子上,分母只是常数且无未知数。 通常情况下,常年用字母 x、y、z 来表示未知数,方程中含有几个不同的未知数就叫做几元,未知数的最高次数是几就叫做几次。 例如:ax+b=c 就是一个一元一次整式方程 【一元一次方程...
阅读全文
摘要:Problem Description “Ladies and Gentlemen, It’s show time! ” “A thief is a creative artist who takes his prey in style... But...
阅读全文
摘要:unique() 位于 头文件中,其作用是元素去重,即删除序列中所有相邻的重复元素。 其删除元素,只是一个伪去除,只是重新排列了序列中的元素,将相邻的重复元素添加到容器末尾,简单来说,使用 unique() 后,容器的长度没有变,只是元素顺序改变了。 其返回...
阅读全文
摘要:Problem Description 度度熊是一只喜欢探险的熊,一次偶然落进了一个m*n矩阵的迷宫,该迷宫只能从矩阵左上角第一个方格开始走,只有走到右上角的第一个格子才算走出迷宫,每一次只能走一格,且只能向上向下向右走以前没有走过的格子,每一个格子中都...
阅读全文
摘要:Problem Description A list of n integers are given. For an integer x you can do the following operations: + let the binary rep...
阅读全文
摘要:Problem Description In a 2D plane N persons are standing and each of them has a gun in his hand. The plane is so big that the p...
阅读全文
摘要:Problem Description John has several lines. The lines are covered on the X axis. Let A is a point which is covered by the most ...
阅读全文
摘要:Problem Description Peter has a string s=s1s2...sn, let suffi=sisi+1...sn...sn be the suffix start with ii-th character of ss. ...
阅读全文
摘要:Problem Description The problem you need to solve here is pretty simple. You are give a function f(A, n), where A is an array o...
阅读全文
摘要:Problem Description During the Warring States Period of ancient China(476 BC to 221 BC), there were seven kingdoms in China ---...
阅读全文
摘要:Problem Description John is a manager of a CPU chip factory, the factory produces lots of chips everyday. To manage large amoun...
阅读全文
摘要:Problem Description Dear contestant, now you are an excellent navy commander, who is responsible of a tough mission currently. ...
阅读全文
摘要:上午补了补题,看了一会树状数组。 下午比赛的题基本是前三天的重现赛,除了之前的题基本都做出来以外,别的题就写出来一道 GCD 的逆推题,晚上补题比较轻松。 这几天总的来说还是感到跟别人的差距了,图论的内容虽然之前看的差不多了,但不一定能做出来,别人虽然没有看完...
阅读全文
摘要:Problem Description Ms.Fang loves painting very much. She paints GFW(Great Funny Wall) every day. Every day before painting, sh...
阅读全文
摘要:Problem Description Dima took up the biology of bacteria, as a result of his experiments, he invented k types of bacteria. Over...
阅读全文
摘要:Problem Description The Old Frog King lives on the root of an infinite tree. According to the law, each node should connect to ...
阅读全文
摘要:Problem Description Given a prime number C(1≤C≤2×105), and three integers k1, b1, k2 (1≤k1,k2,b1≤109). Please find all pairs (a...
阅读全文
摘要:Problem Description A frog has just learned some number theory, and can't wait to show his ability to his girlfriend. Now the...
阅读全文
摘要:Problem Description Consider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal ...
阅读全文
摘要:昨天有事回家,在车站冻了半天,成功的感冒了。。。 早上 8 点多醒了想来实验室,有的头晕量了量体温,有点低烧,就决定再睡一会订好闹钟 10 点多再去实验室,结果一睡睡到快 1 点,打比赛成功的迟到了 1 个多小时。。。 出的第一个题是之前做过的一个区间 dp,...
阅读全文
摘要:Problem Description Dima, Inna and Seryozha have gathered in a room. That's right, someone's got to go. To cheer Seryozha up an...
阅读全文
摘要:Problem Description In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numb...
阅读全文
摘要:Problem Description Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces l...
阅读全文
摘要:Problem Description Given a tree (a connected graph with no cycles), you have to find the farthest nodes in the tree. The edges...
阅读全文
摘要:【定义】 给定一棵树,树中的每条边都有一个权值。 树中两点的距离:连接两点的路径边权之和树的直径:树中最远的两个节点之间的距离树的最长链:连接树中最远的两个结点的路径【实现】 树的直径通常有两种求法,时间复杂度均为O(n)。 假设树以 n 个点 n-1 条边的...
阅读全文
摘要:Problem Description Nura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pou...
阅读全文
摘要:Problem Description Lavrenty, a baker, is going to make several buns with stuffings and sell them. Lavrenty has n grams of dou...
阅读全文
摘要:Problem Description 小度熊拿到了一个无序的数组,对于这个数组,小度熊想知道是否能找到一个k 的区间,里面的 k 个数字排完序后是连续的。 现在小度熊增加题目难度,他不想知道是否有这样的 k 的区间,而是想知道有几个这样的 k 的区间...
阅读全文
摘要:Problem Description There is a tree(the tree is a connected graph which contains n points and n−1 edges),the points are labeled...
阅读全文
摘要:Problem Description According to the Automobile Collision Monitor (ACM), most fatal traffic accidents occur on two-way streets....
阅读全文
摘要:Problem Description The Genographic Project is a research partnership between IBM and The National Geographic Society that is a...
阅读全文
摘要:成功的起晚了。。。醒了快 12 点半了。。。 下午把 STL 常用的容器和算法过了一遍,晚上把之前做过的几个跟 STL 有关的题重新看了下,看了大约三分之一,明天晚上继续吧 下个星期正式开始训练,数学建模也培训一周,早知道这么麻烦当初就不答应学长学姐去建模了。...
阅读全文
摘要:【概述】 map 和 multimap 是映射数据容器,两者均定义与 头文件中,其所有元素都是 pair,pair 的第一个元素被视为键值,第二个元素为实值。 他们是基于某一类型 Key 的键集的存在,提供对 TYPE 类型的数据进行快速和高效的检索,具体实...
阅读全文
摘要:【概述】 set 和 multiset 是集合数据容器,通过链表进行组织,具体实现采用了红黑树的平衡二叉树的数据结构,两者均定义在 头文件中,其会根据特定的规则,自动将元素排序。 两者不同在于,set 不允许元素重复,而 multiset 允许元素重复。 在...
阅读全文
摘要:【概述】 priority_queue(优先队列)是定义在 头文件中的一个模板类,其底层是用堆来实现的。 与 queue(队列)相比,优先队列不是按照入队顺序出队,而是按照队列中元素的优先权出队。默认情况下,按照大者优先的顺序出队,也可以指定算子来指定所需的...
阅读全文
摘要:【概述】 list 与 deque 是在程序设计中会用到的数据容器,STL 提供了方便的链表、双端队列的实现,准确地说,STL 中的 list 与 deque 不同于 pair、vector 等容器,而是对列表和双端队列这两个数据结构的重新包装。 【list ...
阅读全文
摘要:【概述】 vector 是定义在 头文件中的向量容器模版类,其以连续数组的方式存储元素序列,可以将 vector 看作是以顺序结构实现的线性表。 当在程序中需要使用动态数组时,vector 是一个理想的选择,其在使用过程中动态地增长存储空间,存取任何元素都能...
阅读全文
摘要:看了一下午的最小费用最大流,MCMF 算法还算好理解,zkw 和原始对偶看的脑子不够用了,勉勉强强看完了,模版就弄了 MCMF 的,网络流的内容基本算完成了,网络流貌似一直是个难点,题的话一星期做个一两道,坚持下去。 图论内容基本完成了,晚上开始看的数据结构,...
阅读全文
摘要:【概述】 pair 是定义在 头文件中的一个简单的模板类,常用于表示一个二元组或元素对,且其提供了按照字典序对元素对进行大小比较的比较运算符模版函数。 定义: pair pairName 参数:T1 是第一个值的数据类型,T2 是第二个值的数据类型。 【构造...
阅读全文
摘要:终于考完试了,能够好好看看算法了 前几天抽空把最小树形图补了补,把朱刘算法的模板整理了一下,做了两道题。 这两天整理了整理网络流的模板,只弄好了 EK 算法和 Dinic 算法以及求最小割的模板,ISAP 理解的还是不透彻,需要再好好看看,最小费用最大流毫无头...
阅读全文
摘要:Problem Description After a long lasting war on words, a war on arms finally breaks out between littleken’s and KnuthOcean’s ki...
阅读全文
摘要:2-SAT 结束了,这两天看了看差分约束系统,原理不难,关键是建图 这两天把差分约束系统的题做一做,下周开始网络流的内容 ...
阅读全文
摘要:Problem Description 小时候,乡愁是一枚小小的邮票,我在这头,母亲在那头。 —— 余光中 集训是辛苦的,道路是坎坷的,休息还是必须的。经过一段时间的训练,lcy决定让大家回家放松一下,但...
阅读全文
摘要:Problem Description Conflicts are everywhere in the world, from the young to the elderly, from families to countries. Conflicts...
阅读全文
摘要:Problem Description During the kindergarten days, flymouse was the monitor of his class. Occasionally the head-teacher brought ...
阅读全文
摘要:【概述】 如果一个系统由 n 个变量 m 个约束条件组成,形成 m 个形如 的不等式,其中 ,k 是常数,则称这 m 个不等式为差分约束系统(system of difference constraints),亦即,差分约束系统是求解关于一组变量的特殊不等式...
阅读全文
摘要:Problem Description Here is a procedure's pseudocode: go(int dep, int n, int m) begin output the value of dep. if dep #include...
阅读全文
摘要:Problem Description Farmer John's farm has N barns, and there are some cows that live in each barn. The cows like to drop aroun...
阅读全文
摘要:前几天准备 4 级一直没怎么看,考完了又去新生赛帮忙,2-SAT 基本弄完了,但跟二分结合的题还没刷,周三前刷出来。 ...
阅读全文
摘要:Problem Description John is the only priest in his town. September 1st is the John's busiest day in a year because there is an ...
阅读全文
摘要:Problem Description The Public Peace Commission should be legislated in Parliament of The Democratic Republic of Byteland accor...
阅读全文
摘要:Problem Description Up to thirty couples will attend a wedding feast, at which they will be seated on either side of a long tab...
阅读全文
摘要:Problem Description Ratish is a young man who always dreams of being a hero. One day his friend Luffy was caught by Pirate Arlo...
阅读全文
摘要:Problem Description Katu Puzzle is presented as a directed graph G(V, E) with each edge e(a, b) labeled by a boolean operator o...
阅读全文
摘要:【概述】 stack 和 queue 是在程序设计中经常会用到的数据容器,STL 提供了方便的堆栈、队列的实现,准确地说,STL 中的 stack 与 queue 不同于 pair、vector 等容器,而是对栈、队列这三个数据结构的重新包装。 【stack ...
阅读全文
摘要:Problem Description After awarded lands to ACMers, the queen want to choose a city be her capital. This is an important event i...
阅读全文
摘要:【概述】 最小树形图,就是给出一个带权有向图,从中指定一个特殊的结点 root,求一棵以 root 为根的有向生成树 T,且使得 T 中所有边权值最小。 简单来说,最小树形图就是有向图的最小生成树。 【朱刘算法】 1.过程 简单来说,朱刘算法分为四个过程: 1...
阅读全文
摘要:5 天最大流就做了一个题。。。建图建到自闭,终于明白学长说的 “ 网络流模版很简单但是建图你要靠猜 ” 的真正含义了。。。 下午和晚上跟 sdz 补了补 CCPC 的 I 题,一个状压 DP 补到自闭,但着实有不小收获,以后定期在一起做几个题,思维的碰撞很有必...
阅读全文
摘要:Problem Description Input Output Sample Input 3 3 1 1 1 5 1 1 2 2 3 10 1 2 3 4 5 6 7 8 9 10 Sample Output 7 15 127 ...
阅读全文
摘要:Problem Description Mirko works on a pig farm that consists of M locked pig-houses and Mirko can't unlock any pighouse because ...
阅读全文
摘要:Problem Description Every time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means t...
阅读全文
摘要:Problem Description Network flow is a well-known difficult problem for ACMers. Given a graph, your task is to find out the maxi...
阅读全文
摘要:今天看了一天网络流最大流,看到自闭。。。全程就是 wc 这也能实现,wc 这还能实现,wc 为什么这个模版的运行跟我手撸的结果不一样。。。跪了。。。 下午学院开会的时候跟实验室的几个大佬交流了一下进度,发现他们都是看到一半数据结构/图论觉得恶心看不下去了就跑去...
阅读全文
摘要:明天考通信,这几天一直在复习,闲暇时间做了几道差分约束的题换了换脑子,今晚正好弄完差分约束 明天考完后开始网络流的内容 ...
阅读全文
摘要:Problem Description A project can be divided into several parts. Each part should be completed continuously. This means if a pa...
阅读全文
摘要:Problem Description Ali has taken the Computer Organization and Architecture course this term. He learned that there may be dep...
阅读全文
摘要:Problem Description Like everyone else, cows like to stand close to their friends when queuing for feed. FJ has N (2 =0,此外,根据 M...
阅读全文
摘要:Problem Description Once, in one kingdom, there was a queen and that queen was expecting a baby. The queen prayed: ``If my chil...
阅读全文
摘要:Problem Description In a country (my memory fails to say which), the candidates {1, 2 ..., N} are running in the parliamentary ...
阅读全文
摘要:Problem Description Seaco is a beautiful girl and likes play a game called “My Brute”. Before Valentine’s Day, starvae and xing...
阅读全文
摘要:缩点常应用于给一个有向图,求在图中最少要加多少条边能使得该图变成一个强连通图 首先求出该图的各个强连通分量,然后把每个强连通分量看出一个点(即缩点),最后得到了一个有向无环图(DAG) 对于一个DAG,需要添加 max(a,b) 条边才能使其强连通 其中 a ...
阅读全文
摘要:【概述】 Kosaraju 算法是最容易理解,最通用的求强连通分量的算法,其关键的部分是同时应用了原图 G 和反图 GT 。 【基本思想】 1.对原图 G 进行 DFS 搜索,计算出各顶点完成搜索的时间 f 2.计算图的反图 GT,对反图也进行 DFS 搜索,...
阅读全文
摘要:当需要判断图是否为连通图时,可以使用并查集来进行连通分量的统计,若连通分量大于 1,则说明图中存在多个连通分量,图不为连通图。 int n,m;int father[N];int Find(int x){ if(father[x]==-1) ...
阅读全文
摘要:【题目描述】 经过了训练、资金等多方面的准备,处女座终于可以去比赛了!比赛采用codeforces赛制,也就意味着可以插人。现在有一道字符串的题目,处女座在room里看到一个用hash做的,于是决定把它hack掉。这个人的核心代码如下: const i...
阅读全文
摘要:【题目描述】 处女座想出去比赛,但是又不知道学校能不能给到足够的经费。然而处女座是大众粉丝,有着很好的人缘,于是他找了一个在学校管经费的地方勤工俭学偷来了一份报销标准。 由于处女座是万人迷,所以他在中间途径的每一条线路上都会发生一些故事,也许是粉丝给他...
阅读全文
摘要:【题目描述】 众所周知,处女座是数学大师。他定义了k维空间里的处女座点。 对于给出的k维度空间上N个点,处女座点满足:对于这个点P和空间里任意其他两个点 P1、P2,有 dot(PP1,PP2) 即 Pi 不是处女座点,Pj 也不是处女座点,由此可知,...
阅读全文
摘要:上午补了道 2-sat 的题,这类问题还是不太熟练,不是很能准确的找到条件 下午打比赛,立的 flag 成功崩了。。。数组没开小但把精度爆了。。+= 把 + 忘了。。。一道巨水的题把输入看错了。。。大家都是出了 5 道题,就自己排名 100 开外。。。再也不立...
阅读全文
摘要:【题目描述】 处女座靠着自己的家教本领赚够了去比赛的钱,于是开启了疯狂训练。在每个夜深人静第二天不收作业的夜晚,他都会开始刷题。 "今日又是一个刷题的夜晚。"他挑选了n道题开始刷,而题太多,刷不掉,理还乱(呜呜)、自己没有解决的题目每分钟都会给他带来 ...
阅读全文
摘要:【题目描述】 既然昨天晚上处女座已经训练了,明天才要交作业,那今天就是平淡无奇要上课的一天了。 然而处女座也想自己的小姐姐了,可是这节课是老师安排座位,处女座坐在(1,1),而小姐姐坐在(n,m)。他们之间只能通过传纸条的方式来交流感情。对于处女座而言...
阅读全文
摘要:【题目描述】 经过了选号和漫长的等待,处女座终于拿到了给小姐姐定制的手环,小姐姐看到以后直呼666! 处女座其实也挺喜欢6这个数字的,实际上他做手环的时候选取的k=6。所以他对于包含数码6的数字极其敏感。每次看到像4567这样的数字的时候他的心就像触电...
阅读全文
摘要:【理论】 1.距离度量方法:点击这里 2.三角形的面积:点击这里 3.平面分割问题:点击这里 【例题】 Building A New Barn(POJ-3269)(曼哈顿距离):点击这里Aladdin and the Optimal Invitation(Li...
阅读全文
摘要:【海伦公式】 在平面内,有一个三角形,设其三边长分别为 a、b、c,面积为 S ,则有: 其中, double calculate(double a,double b,double c){ double p=(a+b+c)/2; return s...
阅读全文
摘要:【题目描述】 期末考试结束了,处女座发现很多人挂了大物,只能等着第二年重修,还要交400元的重修费。处女座突然想起有个学长和他讲过,如果学校哪一年缺钱了,那一年的大物试卷就会特别难。现在处女座有了所有人的成绩,处女座想知道如果所有挂科的人都在第二年重修,...
阅读全文
摘要:nth_element() 函数位于 头文件中,其作用是求容器中第 k 大的元素并将其放在 k-1 的位置上(下标从 0 开始计数) 其内部是以分治思想实现的,以数组 a[n] 为例,其元素区间为 [0,n-1],经过 nth_element() 函数排序后...
阅读全文
摘要:今天上午补了两道题,然后转接线到了,就弄了一下扩展显示器,下午打比赛果真爽得很,感觉实验室越来越舒服了。。。下一步就该搬到实验室住了。。。 第一道签到题出的比较快,第二道贪心因为没注意数组范围,直接 Runtime,第三道公式题跟学长推了半天,最后用 Java...
阅读全文
摘要:【概述】 Tarjan 算法是基于对图深度优先搜索的算法,每个强连通分量为搜索树中的一棵子树。 搜索时,把当前搜索树中未处理的节点加入一个堆栈,回溯时可以判断栈顶到栈中的节点是否为一个强连通分量。 【基本思路】 定义 DFN(u) 为节点 u 搜索的次序编号(...
阅读全文
摘要:【题目描述】 平面上有一个圆,圆环上按顺时针顺序分布着从1到n,一共n个点。 现在无聊的小希开始按某种顺序对其在圆内两两连线,小希尽量避免让两条线碰撞,可是有的时候,这显然避免不了。 现在你知道小希划线的顺序是什么,请你判断小希在最优情况下,什么时候...
阅读全文
摘要:【题目描述】 小希现在手里有一个连着的两块木条,长度分别为l1,l2,木条之间有一个无摩擦的连接点,木条之间可以相互转动,小希将其称之为双截棍。 现在小希把长为l1的木条的一端放在原点(0,0),任意转动这两根木条,小希想知道,是否有可能通过一种转动方...
阅读全文
摘要:【题目描述】 Applese 有一个QQ群。在这个群中,大家互相请教问题。如 b 向 a 请教过问题,就把 a 叫做是 b 的"老板"。这样一个群中就会有很多老板。 同时规定:如果 a 是 b 的老板,b 是 c 的老板,那么 a 也是 c 的老板。 ...
阅读全文
摘要:【题目描述】 众所周知,Applese 是个很强的选手,它的化学一定很好。 今天他又AK了一套题觉得很无聊,于是想做个毒气炸弹玩。 毒气炸弹需要 k 种不同类型元素构成,Applese一共有 n 瓶含有这些元素的试剂。 已知元素混合遵循 m 条规...
阅读全文
摘要:【题目描述】 Applese 和它的小伙伴参加了一个促销的抽奖活动,活动的规则如下:有一个随机数生成器,能等概率生成 0∼99 之间的整数,每个参与活动的人都要通过它获取一个随机数。最后得到数字最小的 k 个人可以获得大奖。如果有相同的数,那么后选随机数...
阅读全文
摘要:【逐个比较】 bool isPalindrome(string str){ for(int i=0;i<str.size()/2;i++) if(str[i]!=str[str.size()-1-i]) return ...
阅读全文
摘要:【回文串】 回文串,就是一个正读与反读都一样的字符串,比如:abcdcba、zxccxz 等 常见的回文串算法有:求字符串中最长回文串、判断一个字符串是否为回文串、在字符中添加/删除一个字符后是否为回文串等 回文串的判断:点击这里添加/删除字符后是否为回文串:...
阅读全文
摘要:【问题】 给定一个字符串,问对该字符串,是否能通过添加一个字符后变为回文串。 若可以,输出 YES,否则输出 NO 对于该问题,首先要明白,删除一个字符与添加一个字符在判断回文串中是等价的。 【暴力枚举】 先判断字符串是否回文,若是回文,可以在中间添加/删除一...
阅读全文
摘要:【暴力枚举】 求最长回文串最容易的方法就是暴力枚举,求出字符串的每一个子串,然后判断是不是回文,找到最长的那个回文串 求每一个子串的时间复杂度为 O(N^2),判断一个子串是不是回文时间复杂度为 O(N),总的时间复杂度为 O(N^3) string str;...
阅读全文
摘要:【题目描述】 自从 Applese 学会了字符串之后,精通各种字符串算法,比如……判断一个字符串是不是回文串。 这样的题目未免让它觉得太无聊,于是它想到了一个新的问题。 如何判断一个字符串在任意位置(包括最前面和最后面)插入一个字符后能不能构成一个回...
阅读全文
摘要:【题目描述】 Applese 最近又长胖了,于是它打算减肥——练习举重。 他在举重的时候用两只手往不同方向用力,从而把杠铃举起来。 已知 Applese 两只手分别产生的力的大小,以及它们之间的夹角,试求两力合力的大小。 【输入描述】 仅一行三个...
阅读全文
摘要:【题目描述】 精通程序设计的 Applese 叒写了一个游戏。 在这个游戏中,有一个 n×m 的方格,每个格子只能填入 0∼9 这 10 个数字中的一个。要求每两个相邻的格子的数字的和是个素数。 现在已经往格子里面填入了一些数字,没有填入数字的格子显...
阅读全文
摘要:【题目描述】 精通程序设计的 Applese 双写了一个游戏。 在这个游戏中,它被困在了一个 n×m 的迷宫中,它想要逃出这个迷宫。 在迷宫中,有一些方格是水池,只有当 Applese 处于水属性的时候才可以通过;有一些方格是岩浆,只有当 Apple...
阅读全文
摘要:Problem Description Given two integers: n and m and n is divisible by 2m, you have to write down the first n natural numbers in...
阅读全文
摘要:【概述】 组合数学是研究组合与排列问题,其中计数原理、容斥原理、求排列数、求组合数等经常被使用。 【理论相关】 基本计数原理:点击这里容斥原理:点击这里排列数:点击这里组合数:点击这里组合数取模:点击这里卡特兰数列(Catalan):点击这里斯特林数(Stir...
阅读全文
摘要:Problem Description It is 2012, and it's a leap year. So there is a "February 29" in this year, which is called leap day. Inter...
阅读全文
摘要:Problem Description Finally Aladdin reached home, with the great magical lamp. He was happier than ever. As he was a nice boy, ...
阅读全文
摘要:Problem Description If an integer is not divisible by 2 or 5, some multiple of that number in decimal notation is a sequence of...
阅读全文
摘要:【题目描述】 小a正在玩一款即时战略游戏,现在他要用航空母舰对敌方阵地进行轰炸 地方阵地可以看做是n×m的矩形 航空母舰总共会派出q架飞机。 飞机有两种,第一种飞机会轰炸以(xi,yi)为中心,对角线长为li的正菱形(也就是两条对角线分别于x轴y轴平行的...
阅读全文
摘要:【题目描述】 小a和小b来到了一条布满了黄金的街道上。它们想要带几块黄金回去,然而这里的城管担心他们拿走的太多,于是要求小a和小b通过做一个游戏来决定最后得到的黄金的数量。 游戏规则是这样的: 假设道路长度为n米(左端点为0,右端点为n),同时给出一个数...
阅读全文
摘要:STL 中,在 头文件里提供了两个利用二分查找的方法在一个排好序的数组中进行查找。 在一个从小到大的排好序的数组中: lower_bound(begin,end,num):从数组的 begin 位置到 end-1 位置二分查找第一个大于等于 num 的数字,...
阅读全文
摘要:Problem Description A new e-mail service "Berlandesk" is going to be opened in Berland in the near future. The site administrat...
阅读全文
摘要:Problem Description You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1....
阅读全文
摘要:Problem Description Given N numbers, X1, X2, ... , XN, let us calculate the difference of every pair of numbers: ∣Xi - Xj∣ (1 ≤...
阅读全文
摘要:Problem Description What a sunny day! Let’s go picnic and have barbecue! Today, all kids in “Sun Flower” kindergarten are prepa...
阅读全文
摘要:Problem Description 对于一个给定的序列a1,…,an,我们对它进行一个操作reduce(i),该操作将数列中的元素ai和ai+1用一个元素max (ai,ai+1)替代,这样得到一个比原来序列短的新序列。这一操作的代价是max(ai,...
阅读全文
摘要:Problem Description The SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how ma...
阅读全文
摘要:Problem Description You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies,...
阅读全文
摘要:Problem Description Give you three integers n, A and B. Then we define S i = A i mod B and T i = Min{ S k | i-A = 1} Your tas...
阅读全文
摘要:Problem Description You are given a sequence of n numbers a 0,..., a n-1. A cyclic shift by k positions (0=0 的 n 长子序列,那么只要找出最小的...
阅读全文
摘要:Problem Description In a speech contest, when a contestant finishes his speech, the judges will then grade his performance. The...
阅读全文
摘要:Problem Description 小球球是个可爱的孩子,他喜欢玩具,另外小球球有个大大的柜子,里面放满了玩具,由于柜子太高了,每天小球球都会让妈妈从柜子上拿一些玩具放在地板上让小球球玩。 这天,小球球把所有的N辆玩具摆成一排放在地上,对于每辆玩具i...
阅读全文
摘要:【题目描述】 小a的数学基础实在太差了,以至于他只会用计算器算数。他的计算器比较特殊,只有+,−,×,/(即加减乘除)四种运算。 经过一番周折,小a终于算出了他想要的数,但是他却忘记了最初的数是什么。不过幸运的是他记下了整个操作序列,他想请你帮他算出最初...
阅读全文
摘要:Problem Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles...
阅读全文
摘要:【单调栈】 1.原理 单调栈,就是栈内元素保持一定单调性(单调递增或单调递减)的栈,即从栈底到栈顶单调递增或递减。 对于单调递增的栈,如果栈为空或入栈元素值大于等于栈顶元素值,则入栈;否则,若入栈会破坏栈的单调性,因此需要将比入栈元素大的元素全部出栈。 对于单...
阅读全文
摘要:【题目描述】 小希在家里做着作业,外面飘起了斗大的雪花,很冷! 小希把接下来连续的要做作业的时间分成n个单位,每个单位时间内小希都会受到ai的寒冷值侵袭,她可以选择在任何一些时间站起来蹦蹦跳跳,以使得这个单位的寒冷值不侵袭她。 小希最大能承受的寒冷程...
阅读全文
摘要:【题目描述】 小希拿到了一个镜子块,镜子块可以视为一个N x M的方格图,里面每个格子仅可能安装`\`或者`/`的镜子,会反射90°光线,也可能没有安装镜子,使用`.`代替。 但她看不清楚里面的镜子构造是怎样的。 你是这块镜子块的主人,所以你想计算这...
阅读全文
摘要:【题目描述】 精通程序设计的 Applese 叕写了一个游戏。 在这个游戏中,有一个 n 行 m 列的方阵。现在它要为这个方阵涂上黑白两种颜色。规定左右相邻两格的颜色不能相同。请你帮它统计一下有多少种涂色的方法。由于答案很大,你需要将答案对 10^9+...
阅读全文
摘要:【题目描述】 精通程序设计的 Applese 又写了一个游戏。 在这个游戏中,它位于一个 n 行 m 列的方阵中的左上角(坐标为(0, 0),行的序号为 0∼n−1,列的序号为 0∼m−1)。 现在它想不重复地走过所有格子(除了起点),最后回到左上角...
阅读全文
摘要:【题目描述】 处女座为了有更充足的资金和小姐姐一起玩耍,于是就放"高利贷"给小姐姐,一般小姐姐一周就会还钱,而处女座只要10%的利率,这样算下来,如果可以利滚利的话,1元钱经过1年(360天)可以变成51.43元呢,想起来就非常美滋滋哦! 不过总是借钱...
阅读全文
摘要:【题目描述】 课上处女座成功将纸条传给了小姐姐,约下午和小姐姐一起逛街。他们坐在公交车上一起欣赏窗外的广告牌,每一个广告牌都有一个编号,而处女座的视野范围是有限的,每次只能看到连续的p个广告牌。由于处女座是数学大师,他用O(1)的时间算出来了他看到的广告...
阅读全文
摘要:对于一个有桥的连通图,加边变成边双连通图 1.求出所有的桥,然后删除这些桥边。剩下的每个连通块都是一个双连通子图。 2.把每个双连通子图收缩为一个顶点。 3.加回桥边,统计度为1的节点的个数(叶节点的个数),记为 leaf 则:至少在树上加 (leaf+1)/...
阅读全文
摘要:【概念】 1.双连通分量:对于一个无向图,其边/点连通度大于1,满足任意两点之间,能通过两条或两条以上没有任何重复边的路到达的图,即删掉任意边/点后,图仍是连通的 2.分类: 1)点双连通图:点连通度大于 1 的图 2)边双连通图:边连通度大于...
阅读全文
摘要:【概念】 1.割点 1)割点:删除某点后,整个图变为不连通的两个部分的点 2)割点集合:在一个无向图中删除该集合中的所有点,能使原图变成互不相连的连通块的点的集合 3)点连通度:最小割点集合点数 如上图,若去掉 0,则图被分成 12 和 34 两个连通分量;...
阅读全文
摘要:【题目描述】 现在处女座顺利的完成了测验,处女座想要知道知道自己输出的结果是否正确。他希望知道自己有自己输出的数中有多少对是不满足要求的。 更具体的,处女座想知道下面程序段的答案 int main(){ int n; cin>>n; ...
阅读全文
摘要:【题目描述】 一天,处女座在牛客算法群里发了一句“我好强啊”,引起无数的复读,可是处女座发现复读之后变成了“处女座好强啊”。处女座经过调查发现群里的复读机都是失真的复读机,会固定的产生两个错误。一个错误可以是下面的形式之一: 1.将任意一个小写字母替换...
阅读全文
摘要:【概述】 贪心算法是从问题的初始状态出发,通过若干次的贪心选择而得到的最优值的一种求解策略,即贪心策略。 简单来说,贪心策略是一种在每次决策时采取当前意义下最优策略的算法,做出的选择至少在某种约束条件下的局部最优解或较优解,并不一定是全局的最优解或较优解,但在...
阅读全文
摘要:【题目描述】 快要期末考试了,处女座现在有n门课程需要考试,每一门课程需要花ai小时进行复习,考试的起始时间为bi,处女座为了考试可以不吃饭不睡觉,处女座想知道他能否复习完所有的科目(即在每一门考试之前复习完该科目)。每一门课的考试时间都为两小时。 【...
阅读全文
摘要:1.简单理解 在线与离线可以简单的理解为对所有的操作是否需要读入完毕。 2.基本区分 在线的要求是可以不用先直到所有的操作(询问、修改等),边读入边执行,类似走一步做一步的思想。 离线的要求与在线相反,必须要求知道所有的操作,类似所有操作,回头再做的思想,一般...
阅读全文
摘要:Problem Description 百小度是一个ACMer,也是一个超级赛亚人,每个ACMer都有一个战斗力,包括百小度。
所谓超级赛亚人的定义,是说如果在对抗中刚好接近极限状态,那就会激发斗志,实力提升. 具体来说,就是百小度现在要接...
阅读全文
摘要:好几天没写训练日记了。。。 最近几天题出的不多,大部分时间都在补题。。。 今天做了两道模版题,一道最大团的,现学的 Bron-Kerbosch 算法,一道树形 DP 的题,最后时间不够了没交上。。。 ...
阅读全文
摘要:Problem Description You are given array a with n integers and m queries. The i-th query is given with three integers li, ri, xi...
阅读全文
摘要:Problem Description You will be given two sets of integers. Let's call them set A and set B. Set A contains n elements and set ...
阅读全文
摘要:Problem Description In a computer network a link L, which interconnects two servers, is considered critical if there are at lea...
阅读全文
摘要:Problem Description ACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个...
阅读全文
摘要:Problem Description Given a graph G(V, E), a clique is a sub-graph g(v, e), so that for all vertex pairs v1, v2 in v, there exi...
阅读全文
摘要:【问题描述】 当 G′ 是图 G 的子图,且 G′ 是关于 V′ 的完全图时,子图 G' 为图 G 的团;当 G' 是团,且不是其他团的子集时,G' 为图 G 的极大团;当 G' 是极大团时,且点数最多,G' 为图 G 最大团 当 G′ 中所有点不相邻,最大...
阅读全文
摘要:Problem Description Betty owns a lot of ponds, some of them are connected with other ponds by pipes, and there will not be more...
阅读全文
摘要:Problem Description A bit is a binary digit, taking a logical value of either 1 or 0 (also referred to as "true" or "false" res...
阅读全文
摘要:这里写自定义目录标题 欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与...
阅读全文
摘要:Problem Description It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a ...
阅读全文
摘要:给大家带来一个简单c++计算器 代码: #includeusing namespace std;int jisuan(int a,c...
阅读全文

浙公网安备 33010602011771号