划分那个序列,没必要完全覆盖原序列.对于划分出来的每个序列,对于某个值v,要么全都在该序列,要么全都不在该序列.  一个序列的价值是所有不同的值的异或和.整个的价值是所有划分出来的序列的价值之和.    求整个的价值的最大值   f(i)表示最后一个划分序列的右端点为i时,1~i的答案. f(i)=max{max{f(j)}(1<=j<i)+xorsum(j+1,i)(j+1到i的区间合法)}(1<=i<=n) 需要在转移的时候,顺便处理f(i)的前缀max. 最终的答案就是所有f…
http://codeforces.com/contest/811/problem/C 题意: 给出一行序列,现在要选出一些区间来(不必全部选完),但是相同的数必须出现在同一个区间中,也就是说该数要么不选,选了就必须出现在同一个区间,最后累加区间不同的数的异或值. 思路: 先预处理,求出每个数的左位置和右位置. d[i]表示分析到第 i 位时的最大值. #include<iostream> #include<algorithm> #include<cstring> #i…
地址:http://codeforces.com/contest/811/problem/D 题目: D. Vladik and Favorite Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output This is an interactive problem. Vladik has favorite game, in…
B. Vladik and Complicated Book time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vladik had started reading a complicated book about algorithms containing n pages. To improve understanding o…
A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. Afte…
那个人第一步肯定要么能向下走,要么能向右走.于是一定可以判断出上下是否对调,或者左右是否对调. 然后他往这个方向再走一走就能发现一定可以再往旁边走,此时就可以判断出另一个方向是否对调. 都判断出来以后,跑个spfa或者bfs就行了. 细节较多……有一些边界情况需要处理.比如终点在第一行或者第一列的情况. #include<cstdio> #include<queue> #include<cstring> #include<algorithm> using n…
A. Vladik and Courtesy 题面 At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. After that Valera gave Vladik 2 his candies, so that no one thought that he was less generous. Vladik for same…
A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. Afte…
A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. Afte…
E. Vladik and cards 题目链接 http://codeforces.com/contest/743/problem/E 题面 Vladik was bored on his way home and decided to play the following game. He took n cards and put them in a row in front of himself. Every card has a positive integer number not e…
C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction as a sum of three distinct posit…
A. Vladik and flights 题目链接 http://codeforces.com/contest/743/problem/A 题面 Vladik is a competitive programmer. This year he is going to win the International Olympiad in Informatics. But it is not as easy as it sounds: the question Vladik face now is…
A. Vladik and Courtesy time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. Afte…
http://codeforces.com/contest/754/problem/C C. Vladik and chat time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recently Vladik discovered a new entertainment — coding bots for social netwo…
A. Vladik and Courtesy 2 seconds 256 megabytes   At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. After that Valera gave Vladik 2 his candies, so that no one thought that he was less gen…
传送门 Description Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction   as a sum of three distinct positive fractions in form . Help Vladik with that, i.e for a g…
E. Vladik and cards time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vladik was bored on his way home and decided to play the following game. He took n cards and put them in a row in front…
CodeForces - 811A A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his can…
Codeforces Round #539 (Div. 2) A - Sasha and His Trip #include<bits/stdc++.h> #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<queue> #incl…
Problem  Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 3000 mSec Problem Description Input Output Sample Input 6 8abdabc+ 1 a+ 1 d+ 2 b+ 2 c+ 3 a+ 3 b+ 1 c- 2 Sample Output YESYESYESYESYESYESNOYES 题解:动态规划,意识到这个题是动态规划之后难点在于要优化什么东西,本题…
Codeforces Round #598 (Div. 3)- E. Yet Another Division Into Teams - 动态规划 [Problem Description] 给你\(n\)个数,将其划分为多组,对于每个组定义其\(d\)值为 组内的最大值减最小值,问如何划分使得最终所有组的\(d\)值之和最小.每个组至少要保证有\(3\)个数. [Solution] 将所有值从小到大排序,然后我们知道最多有\(5\)个人划分到同一组中,如果有\(6\)个人,那么划分为两组一定比…
Codeforces Round #297 (Div. 2)E. Anya and Cubes Time Limit: 2 Sec  Memory Limit: 512 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/E Description Anya loves to fold and stick. Today she decided to do just that. Anya has n c…
Codeforces Round #544 (Div. 3) D. Zero Quantity Maximization 题目链接:https://codeforces.com/contest/1133/problem/D 题意: 给出ai,bi,然后让你确定一个数d,令ci=d*ai+bi,问怎么确定这个d,有最多的ci为0. 题解: 这个题其实不难,但是我没做起,哎,初中数学没学好啊..其实做法就是map+pair就行了. 但是这里要注意一个问题,就是当ai=bi=0的时候,d是可以任意取值…
Codeforces Round #538 (Div. 2) 题目链接:https://codeforces.com/contest/1114 A. Got Any Grapes? 题意: 有三个人,有三种食物,食物对应的数量为a,b,c,三个人需要的食物量分别为x,y,z. 现在第一个人只吃第一种食物,第二个人只吃前两种食物,第三个人都要吃.问准备的食物数量是否能够满足这三个人. 题解: 简单模拟一下就行了. 代码如下: #include <bits/stdc++.h> using name…
Codeforces Round 363 Div. 1 题目链接:## 点击打开链接 A. Vacations (1s, 256MB) 题目大意:给定连续 \(n\) 天,每天为如下四种状态之一: 不能进行运动或比赛 可以进行运动但不能比赛 可以进行比赛但不能运动 可以进行比赛或运动 对于每天,可以根据当天的状态选择运动,比赛或休息.但不能连续两天的选择均为运动或均为比赛.求在这 \(n\) 天中最少需要休息多少天. 数据范围:\(n \leq 100\) 简要题解:令 \(f_{i,0},f_…
Codeforces Round 367 Div. 2 点击打开链接 A. Beru-taxi (1s, 256MB) 题目大意:在平面上 \(n\) 个点 \((x_i,y_i)\) 上有出租车,每辆出租车的行驶速度为 \(v_i\),求所有出租车到点 \((a,b)\) 的时间中的最短时间. 数据范围:\(-100 \leq a,b,x_i,y_i \leq 100\),\(v_i \leq 100\),\(n \leq 1000\) 简要题解:依次求出所有的时间,取最小值即可. 时空复杂度…
这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. Angry Students 题目大意:有t队学生,每个学生有两种状态,生气(A)或不生气(P).(话说为什么生气的戴着圣诞帽哇)所有生气的人都会往前一个人丢雪球,被丢到的人也会变得生气,也会丢雪球.问你每队人中最后一个学生变得生气的时刻. 这题就是统计最长的连续的'P'当然前提是左边有生气的人. 代码…
Codeforces Round #801 (Div. 2) and EPIC Institute of Technology Round C - Zero Path 在这道题目中,不可以真正地进行寻找必须另想办法. 考虑到只能向右面还有下面走,所以对于一个点,它只可能有已经走过的点转移过来,这让我想起来动态规划. 动态规划考虑最优解,这里所需要求的是0,不可以直接考虑是否与0相接近,需要考虑其他解法. 最大值以及最小值是唯一的,所以可以通过动态规划,最终求出目的地的最大数字以及最小数字. 证明…
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate it n = int(raw_input()) s = "" a = ["I hate that ","I love that ", "I hate it","I love it"] for i in ran…
Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/output 1 s, 256 MB    x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB    x1462 C Vasya and String standard input/output 1 s, 256 MB    x1393…