题目链接: http://codeforces.com/contest/706/problem/D D. Vasiliy's Multiset time limit per test:4 secondsmemory limit per test:256 megabytes 问题描述 Author has gone out of the stories about Vasiliy, so here is just a formal task description. You are given q…
D. Vasiliy's Multiset time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Author has gone out of the stories about Vasiliy, so here is just a formal task description. You are given q queries a…
题目链接:Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset 题意: 给你一些操作,往一个集合插入和删除一些数,然后?x让你找出与x异或后的最大值 题解: trie树xjb搞就行,每次要贪心,尽量满足高位为1. #include<bits/stdc++.h> #define F(i,a,b) for(int i=a;i<=b;i++) using namespace std; namespace trie { )*; ],ed=-,c…
Vasiliy's Multiset 题目链接: http://codeforces.com/contest/706/problem/D Description Author has gone out of the stories about Vasiliy, so here is just a formal task description. You are given q queries and a multiset A, initially containing only integer…
D. Vasiliy's Multiset time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Author has gone out of the stories about Vasiliy, so here is just a formal task description. You are given q queries a…
D. Vasiliy's Multiset time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Author has gone out of the stories about Vasiliy, so here is just a formal task description. You are given q queries a…
http://codeforces.com/contest/706/problem/D 题意:有多种操作,操作1为在字典中加入x这个数,操作2为从字典中删除x这个数,操作3为从字典中找出一个数使得与给定的数的异或值最大. 思路: 因为这道题目涉及到删除操作,所以用一个变量cnt来记录前缀的数量,加入时就+1,删除时就减1.查询时前缀数量>0时就说明是存在的. #include<iostream> #include<cstdio> #include<cstring>…
Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solving different tasks. Today he found one he wasn't able to solve himself, so he asks you to help. Vasiliy is given n strings consisting of lowercase Engl…
Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bough…
Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as possible. New app suggested n available Beru-taxi…
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\) 简要题解:依次求出所有的时间,取最小值即可. 时空复杂度…
题目链接:Codeforces Round #367 (Div. 2) C. Hard problem 题意: 给你一些字符串,字符串可以倒置,如果要倒置,就会消耗vi的能量,问你花最少的能量将这些字符串排成字典序 题解: 当时1点过头太晕了,看错题了,然后感觉全世界都会,就我不会,- -!结果就是一个简单的DP, 设dp[i][0]表示第i个字符串不反转的情况,dp[i][1]表示第i个字符串反转的情况 状态转移方程看代码 #include<bits/stdc++.h> #define F(…
A题 Beru-taxi 随便搞搞.. #include <cstdio> #include <cmath> using namespace std; int a,b,n; struct _ { int x,y,v; }p[]; double dis2(_ A) { return (a - A.x) * (a - A.x) + (b - A.y) * (b - A.y); } int main() { scanf("%d%d%d", &a, &b…
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #include<iostream> #include<algorithm> #include<string.h> #include<stdio.h> #include<math.h> #include<vector> using namespace…
吐槽:只能说是上分好场,可惜没打,唉 A:Beru-taxi (水题,取最小值) #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string>…
A. Beru-taxi time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as…
A. Beru-taxi time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as…
http://codeforces.com/group/1EzrFFyOc0/contest/706/problem/D 题目:就是有3种操作 + x向集合里添加 x - x 删除x元素,(保证存在 ? x 查询 x |  集合中元素的最大值 思路:就是利用字典树,从高位到低位进行贪心. 比如说给一个数 x=3  , 对x 各位取反(二进制)(x=~x ), 于是就是 1-0-0-1: 拿 1-0-0-1,从左到右(从高位到地位)顺序,来在字典树中寻找.如果能找到(if ),就接着找下去: 如果…
Hard problem 题意: 有n个字符串,对第i个字符串进行反转操作代价为ci. 要使n个字符串按照字典序从小到大排列,最小的代价是多少. 题解: 反转就是reverse操作,比如说45873反转之后只能是37845,不能是别的,当时就这没有理解好,所以没继续去想,其实可以假设这样,之后来一发的,如果当时这样不就对了嘛. 一行只有反转或不反转,要求最小代价,有道01背包的意思,所以就要dp试试,dp[i]代表第i的串的最小代价,但是怎么继续推呢?,没有办法,就再多开一维,另一维只要代表2个…
题意与分析 题意:给出\(n\)个字符串,可以反转任意串,反转每个串都有其对应的花费\(c_i\).经过操作后是否能满足字符串\(\forall i \in [1,n] \text{且} i \in R_+, str[i]\ge str[i-1]\),若能输出最小花费,否则输出-1. 分析:经过各种字符串dp血虐,应该会有个直觉:\(dp[i]\)表示前\(i\)个串的最小花费.但是好像不太够:没有保存反转.因此,在dp中,如果状态不够,那就加维度保存状态.这里就是:我们定义\(dp[i][0]…
D. Acyclic Organic Compounds   You are given a tree T with n vertices (numbered 1 through n) and a letter in each vertex. The tree is rooted at vertex 1. Let's look at the subtree Tv of some vertex v. It is possible to read a string along each simple…
// trie树 Codeforces Round #367 D Vasiliy's Multiset // 题意:给一个集合,初始有0,+表示添加元素,-去除元素,?询问集合里面与x异或最大的值 // 思路:思路很好想,建立trie树,再贪心当前位是1则选0,0则选1 #include <bits/stdc++.h> using namespace std; #define LL long long const double inf = 123456789012345.0; const LL…
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…
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输出”#Color”,如果只有”G”,”B”,”W”就输出”#Black&White”. #include <cstdio> #include <cstring> using namespace std; const int maxn = 200; const int INF =…
 cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....       其实这个应该是昨天就写完的,不过没时间了,就留到了今天.. 地址:http://codeforces.com/contest/651/problem/A A. Joysticks time limit per test 1 second memory limit per test 256…
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard in…
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his info…
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Victor adores the sets theory. Let us remind you that a set is a group of…
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给出的01序列相等(比较时如果长度不等各自用0补齐) 题解: 1.我的做法是用Trie数来存储,先将所有数用0补齐成长度为18位,然后就是Trie的操作了. 2.官方题解中更好的做法是,直接将每个数的十进制表示中的奇数改成1,偶数改成0,比如12345,然后把它看成二进制数10101,还原成十进制是2…