By csacademy, 9 years ago, Hello, Codeforces! We have recently launched a graph editor tool. Feel free to use it whenever you want to visualise or create a medium size graph. It currently supports up to 30 nodes
题目链接:https://csacademy.com/contest/arhiva/#task/force_graph/ 大意是有若干个节点,每个节点对应一个二维坐标,节点之间相互有斥力存在。同时有些节点之间有变存在。对于有边存在的节点,他们互相的斥力大小为F1*dis值,否则则为F2*dis值,其中dis值为节点之间的欧氏距离。问每个节点受到的斥力大小。 这个其实就...
If the graph is connected (but not a star), we again choose all the white vertices followed by the black ones and we'll always find a pair of vertices of different colors that don't share an edge. Knowing this, we can just build the solution incrementally. At each step we maintain...
Node66:[1, 2, 5][1,2,5] In this problem we are concerned with the two most popular algorithms for traversing a graph: theBreadth First Search (BFS)and theDepth First Search (DFS). The BFS pushes the starting node in a queue. While the queue is not empty, we pop the first node ...
题目链接:https://csacademy.com/contest/arhiva/#task/swap_pairing/ 大意是给2*n个包含n种数字,每种数字出现恰好2次的数列,每一步操作可以交换相邻的两个数字,问最少需要操作多少次,可以使得所有的同种数字都相邻。 我的做法是考虑不同的数对的数字在原来数列中的位置关系,有三大类,如果我们用[]和{}表示...
I am trying to solve manhattan centre from cs academy. I am thinking to apply binary search on answer for x between 1 and 100000000. According to me the graph of the function will be a parabola.So what I am doing is I am calculating three values one at mid,mid+1 and mid-1 and ch...
If the graph is connected (but not a star), we again choose all the white vertices followed by the black ones and we'll always find a pair of vertices of different colors that don't share an edge. Knowing this, we can just build the solution incrementally. At each step we maintain...
One of the most popular algorithms for traversing a graph is theDepth First Search (DFS). The DFS is usually implemented as a recursive function. First we call the function for the starting node. For each call, we go through the adjacency list of the current node, and recursively call the...
Bad Triplet Time limit:1000 ms Memory limit:128 MB You are given a simple, undirected, connected graph withNN nodes andMM edges. Find33 nodesAA,BB andCCsuch that the minimum distance betweenA - BA−B,A-CA−C andB-CB−C is the same. ...
题目链接:https://csacademy.com/contest/arhiva/#task/long_journey/ 大意是有一张无向不带权的图,两个人同时从s点出发,分别前往a点和b点,且每个人应该走s到a和s到b的最短路,问他们可以一起走的最大距离是多少。 我一开始的想法是以s为源点bfs,做出所有点的前驱,然后判断a回到s和b回到s有多少点是共...