题意:n个点,m条无向边,每个边有权值,给你 s 和 t,问你至多删除两条边,让s,t不连通,问方案的权值和最小为多少,并且输出删的边 分析:n<=1000,m是30000  s,t有4种情况(首先定义完全不相同的路径,即两条路径上没有一条边是一样的) 1. s,t本就不连通,输出0即可 2. s,t连通但是只有一条完全不相同的路径 3. s,t连通但是只有两条条完全不相同的路径 4. s,t连通但是有>=3条完全不相同的路径(这种情况无解) 情况1预处理即可,要解决的问题是2,3,4乍一看,…
E. Simple Skewness time limit per test:3 seconds memory limit per test:256 megabytes input:standard input output:standard output Define the simple skewness of a collection of numbers to be the collection's mean minus its median. You are given a list…
/* 题意:给出立方体的每个顶点的坐标(是由源坐标三个数某几个数被交换之后得到的!), 问是否可以还原出一个立方体的坐标,注意这一句话: The numbers in the i-th output line must be a permutation of the numbers in i-th input line! 思路: 我们只要对输入的每一行数据进行枚举每一个排列, 然后检查时候能构成立方体就好了! 检查立方体:找到最小的边长的长度 l, 统计边长为l, sqrt(2)*l, sqrt…
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means chang…
题意:进行若干场比赛,每次比赛两人对决,赢的人得到1分,输的人不得分,先得到t分的人获胜,开始下场比赛,某个人率先赢下s场比赛时, 游戏结束.现在给出n次对决的记录,问可能的s和t有多少种,并按s递增的方式输出. 析:如果枚举s 和 t,那么一定会超时的,所以我们考虑是不是可以不用全枚举.我们只要枚举 t ,然后每次都去计算 s. 首先我们先预处理两个人的获得第 i 分时是第几场比赛.然后每次枚举每个 t,每次我们都是加上t,所以总的时间复杂度为 n*logn. 完全可以接受,注意有几个坑,首先…
A. Flipping Game time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub got bored, so he invented a game to be played on paper. He writes n integers a1, a2, ..., an. Each of those integers c…
B. Covered Path Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/problem/B Description The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v1 meters per…
题目链接: http://www.codeforces.com/contest/666/problem/B 题意: 给你n个城市,m条单向边,求通过最短路径访问四个不同的点能获得的最大距离,答案输出一个满足条件的四个点. 题解: 首先预处理出任意两点的最短距离,用队列优化的spfa跑:O(n*n*logn) 现依次访问四个点:v1,v2,v3,v4 我们可以枚举v2,v3,然后求出v2的最远点v1,v3的最远点v4,为了保证这四个点的不同,直接用最远点会错,v1,v4相同时还要考虑次最远点来替换…
题目链接:A. Sereja and Swaps 题意:给定一个序列,能够交换k次,问交换完后的子序列最大值的最大值是多少 思路:暴力枚举每一个区间,然后每一个区间[l,r]之内的值先存在优先队列内,然后找区间外假设有更大的值就替换掉. 求出每一个区间的最大值,最后记录下全部区间的最大值 代码: By lab104_yifan, contest: Codeforces Round #243 (Div. 2), problem: (C) Sereja and Swaps, Accepted, #…
题意:求定 n 个数,求有多少对数满足,ai^bi = x. 析:暴力枚举就行,n的复杂度. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <c…