CodeForce 339:A+B+C】的更多相关文章

A题:水题.. #include<stdio.h> #include<string.h> ; char s[ maxn ]; int main(){ //freopen("in.txt","r",stdin); while( scanf("%s",s)!=EOF ){ int len = strlen(s); ,c2 = ,c3 = ; ;i<len;i++ ){ ' ) c1++; ' ) c2++; ' ) c3…
Peter and Snow Blower 题意:有n(3 <= n <= 100 000)个点的一个多边形,这个多边形绕一个顶点转动,问扫过的面积为多少? 思路:开始就认为是一个凸包的问题,像poj2187求点对平方的最大值一样,但是有一个点是确定的(ps:这道题在div1里面可是A啊!这么复杂?),所以直接求解即可,时间复杂度也就O(n);还有就是怎么求多边形到确定点的最小距离呢?这就不只是暴力求点对之间的距离这么简单了.因为一个多边形绕一个点转动时,有时候是定点到边的距离,所以转化为了点…
题意(CodeForces 614D) 每个人有\(n(n\le 10^5)\)个技能,技能等级都在\([0,10^9]\)的范围,每个技能有一个当前等级,所有技能的最高等级都为A.一个人的力量被记做以下两项的和: 1. 顶级技能的个数 *cf 2. 最低等级的技能 *cm 每个单位的钱能够提升一级力量.我们希望花尽可能少的钱,使得力量尽可能高. 分析 我二分的功力还是不足,要多努力.这题其实是一个非常明显的暴力:我们枚举提高到A的等级的个数(到不能提升为止),枚举这种情况下,我们能够令把多少人…
[codeforces 339]E. Three Swaps 试题描述 Xenia the horse breeder has n (n > 1) horses that stand in a row. Each horse has its own unique number. Initially, the i-th left horse has number i. That is, the sequence of numbers of horses in a row looks as foll…
[codeforces 339]D. Xenia and Bit Operations 试题描述 Xenia the beginner programmer has a sequence a, consisting of 2n non-negative integers: a1, a2, ..., a2n. Xenia is currently studying bit operations. To better understand how they work, Xenia decided t…
[codeforces 339]C. Xenia and Weights 试题描述 Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by on…
Bahosain is walking in a street of N blocks. Each block is either empty or has one lamp. If there is a lamp in a block, it will light it’s block and the direct adjacent blocks. For example, if there is a lamp at block 3, it will light the blocks 2, 3…
A. Link/Cut Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifica…
e,还是写一下这次的codeforce吧...庆祝这个月的开始,看自己有能,b到什么样! cf的第二题,脑抽的交了错两次后过了pretest然后system的挂了..脑子里还有自己要挂的感觉,果然回头一小改就过了! 只能呵呵...C题还是看了下,又没写,也许写不出吧...的确时候还是看了别人的额,自己写只到第8组WA! 希望下次少,一点! 哎,等我不,b了这个世界也许都不同了!…
http://www.python.org/dev/peps/pep-0339/ PEP: 339 标题: CPython的编译器设计 版本: 425fc5598ee8 最后修改: 2011-01-18 0时37分50秒+0000(星期二,2011年1月18日) 作者: :布雷特大炮<brett python.org> 状态: 撤回 类型: 信息 内容类型: 文字/ X-RST 创建: 02日,2005 历史后:   内容 抽象 解析树 抽象语法树(AST) 内存管理 AST解析树 控制流图…
339. [NOI2005] 维护数列 时间限制:3 s   内存限制:256 MB [问题描述] 请写一个程序,要求维护一个数列,支持以下 6 种操作:(请注意,格式栏 中的下划线‘ _ ’表示实际输入文件中的空格) 操作编号 输入文件中的格式 说明 1.  插入 INSERT_posi_tot_c1_c2_..._ctot 在当前数列的第 posi 个数字后插入 tot 个数字:c1, c2, …, ctot:若在数列首插 入,则 posi 为 0 2.  删除 DELETE_posi_to…
又水了一发Codeforce ,这次继续发发题解顺便给自己PKUSC攒攒人品吧 CodeForces 438C:The Child and Polygon: 描述:给出一个多边形,求三角剖分的方案数(n<=200). 首先很明显可能是区间dp,我们可以记f[i][j]为从i到j的这个多边形的三角剖分数,那么f[i][j]=f[i][k]*f[j][k]*(i,j,k是否为1个合格的三角形) Code: #include<cstdio> #include<iostream> #…
codeforce 375_2 标签: 水题 好久没有打代码,竟然一场比赛两次卡在边界条件上....跪 b.题意很简单...纯模拟就可以了,开始忘记了当字符串结束的时候也要更新两个值,所以就错了 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N = 300; char a[N]; int main() { int n; int l; int su…
codeforce 367dev2_c dp 标签: dp 题意: 你可以通过反转任意字符串,使得所给的所有字符串排列顺序为字典序,每次反转都有一定的代价,问你最小的代价 题解:水水的dp...仔细想想就有了,一个位置要么反转要么就不反转...保证在满足条件时候转移 扔个代码: #include<cstdio> #include<cstring> #include<string> #include<iostream> #include<algorith…
三维dp&codeforce 369_2_C 标签: dp codeforce 369_2_C 题意: 一排树,初始的时候有的有颜色,有的没有颜色,现在给没有颜色的树染色,给出n课树,用m种燃料涂,将相邻相同颜色的树划为一组,最后使得组数为k,并且所用燃料的量最小,给出了每棵树涂j种燃料的用量,如果存在这种涂法输出最小用量,不存在输出-1: 题解: 很容易看出是一个三维dp, dp[i][j][k] 表示处理到第i棵树,最后一棵树为颜色j,现在已经分成的组数为k的时候的最小用量 转移方程如果当前…
强连通分量 标签: 图论 算法介绍 还记得割点割边算法吗.回顾一下,tarjan算法,dfs过程中记录当前点的时间戳,并通过它的子节点的low值更新它的low,low值是这个点不通过它的父亲节点最远可以到达的dfn值最小的点,如果当前的节点的low>他父亲节点的dfn说明它不能通过其他的边到达它的父亲,那么它和他父亲的这条边就是割边,在这个算法中有三个标号,VIS数组,标记为0表示没有被访问到,标记为1表示这个点正在搜索它的自孩子,标记为2表示这个点已经处理过了,就是已经找到了它属于哪个联通块,…
第一次在python中使用OpenCV(cv2),运行时报错opencv-3.3.1\modules\highgui\src\window.cpp:339: error: (-215) size.width>0 && size.height>0 in function cv::imshow 源码如下: import cv2 img = cv2.imread('路.jpg') cv2.namedWindow("w") cv2.imshow('w',img) c…
[树状数组]区间出现偶数次数的异或和(区间不同数的异或和)@ codeforce 703 D PROBLEM 题目描述 初始给定n个卡片拍成一排,其中第i个卡片上的数为x[i]. 有q个询问,每次询问给定L和R表示,询问的区间[L,R]内的卡片所有出现了偶数次的数的异或和是多少. 输入 输入一行两个整数n,q. 第二行n个整数,第i个数为x[i]. 接下来q行,每行两个整数L和R,表示询问的区间. 输出 输出q行,其中第i行表示第i次询问的区间出现偶数次的数的异或和. 样例输入 3 1 3 7…
Codeforces 339 D 题意:给定\(2^n​\)个数字,现在把它们进行如下操作: 相邻的两个数取\(or\) 相邻的两个数取\(xor\) 以此类推,直到剩下一个数. 问每次修改一个数字,最后得到的那个数是多少. 思路:线段树. 但是在\(pushup\)的过程中要看当前节点到底层的叶子距离有多长, 如果是奇数就\(or\),否则\(xor\). 单点修改,查询根即可.…
现象: 操作系统:centos 7.2 kernel 3.10.0-327.el7.x86_64 mesos:1.3.0 docker:docker-17.06.0-ce 在做mesos验证时,通过marathon下发容器,发现在多个mesos-slave节点上下发容器均以失败告终. marathon: mesos: 分析: #在任意1个mesos节点上查看docker下发容器的信息 [root@mesos-node1 ~]# docker ps -a #再查看每个下发失败的容器的信息,如id为…
codeforce 7C C. Line time limit per test1 second memory limit per test256 megabytes A line on the plane is described by an equation Ax + By + C = 0. You are to find any point on this line, whose coordinates are integer numbers from  - 5·1018 to 5·101…
An arithmetic progression is such a non-empty sequence of numbers where the difference between any two successive numbers is constant. This constant number is called common difference. For example, the sequence 3, 7, 11, 15 is an arithmetic progressi…
286. Walls and Gates DFS: 思路是,搜索0的位置,每找到一个0,以其周围四个相邻点为起点,开始 DFS 遍历,并带入深度值1,如果遇到的值大于当前深度值,将位置值赋为当前深度值,并对当前点的四个相邻点开始DFS遍历,注意此时深度值需要加1 class Solution { public void wallsAndGates(int[][] rooms) { for(int i = 0; i < rooms.length; i++){ for(int j = 0; j <…
You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence aij such that the sum of numbers in this subsequence is divisible by m. Input The first line contains two numbers, n and m…
In the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize a demonstration at one of th…
Two players play a game. The game is played on a rectangular board with n × m squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player…
To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractions are represented as two sets of integers. The product of numbers from the first set gives the fraction numerator, the product of numbers from the se…
Prime Number CodeForces - 359C Simon has a prime number x and an array of non-negative integers a1, a2, ..., an. Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and…
A tournament is a directed graph without self-loops in which every pair of vertexes is connected by exactly one directed edge. That is, for any two vertexes u and v (u ≠ v) exists either an edge going from u to v, or an edge from v to u. You are give…
原题 Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- whose elements may also be integers or other lists. Example 1: Given the list [[1,1],2,[1,1]], ret…