Codeforces 996E Leaving the Bar (随机化)】的更多相关文章

题目连接:Leaving the Bar 题意:给你n个向量,你可以加这个向量或减这个向量,使得这些向量之和的长度小于1.5e6. 题解: 按照正常的贪心方法,最后的结果有可能大于1.5e6 .这里我们可以加一些随机性,多次贪心,直到结果满足题意.正解是每三个向量中都能找到两个向量合起来 <= 1e6,然后不断合并,最后只会剩下一个或者两个向量,如果一个向量肯定 <= 1e6, 如果是两个向量一定 <= 1.5 * 1e6.这是我第一遇到随机化的题~~~ #include<bits…
D. Leaving Auction time limit per test: 2 seconds memory limit per test:256 megabytes input:standard input output:standard output There are n people taking part in auction today. The rules of auction are classical. There were n bids made, though it's…
Chocolate Bar 题意: 有一个n*m(1<= n,m<=30)的矩形巧克力,每次能横向或者是纵向切,且每次切的花费为所切边长的平方,问你最后得到k个单位巧克力( k <= min(n*m,50) )的最小花费是多少? 思路: 数据规模不大,但是贪心不能得到最优解,很自然想到了dp;里面涉及到行的减少和列的减少,在dp[][]表示中必定要以行数和列数作为dp的含义,但是好像这还不够,如果单单只是一个二维的dp[][]那这个表示的是取了(或者还需)几个单位巧克力呢? ==>…
题目描述 For a vector v⃗=(x,y) \vec{v} = (x, y) v=(x,y) , define ∣v∣=x2+y2 |v| = \sqrt{x^2 + y^2} ∣v∣=x2+y2​ . Allen had a bit too much to drink at the bar, which is at the origin. There are n n n vectors v1⃗,v2⃗,⋯,vn⃗ \vec{v_1}, \vec{v_2}, \cdots, \vec{…
题目链接: E. Chocolate Bar time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a rectangular chocolate bar consisting of n × m single squares. You want to eat exactly k squares, so you ma…
For a vector →v=(x,y)v→=(x,y), define |v|=√x2+y2|v|=x2+y2. Allen had a bit too much to drink at the bar, which is at the origin. There are nn vectors →v1,→v2,⋯,→vnv1→,v2→,⋯,vn→. Allen will make nn moves. As Allen's sense of direction is impaired, dur…
题目链接:http://codeforces.com/problemset/problem/749/D 题意:就是类似竞拍,然后报价肯定要比上一个高,然后查询输入k个数表示那些人的竞拍无效, 输出最后谁竞拍到了花了多少钱. 比较简单的二分只要找到删除无效人后最大的两个人然后用第二大的那个人的最大竞拍价二分查找 最大的那个人中的竞拍价,然后的得到的第一个大于等于的值即可. #include <iostream> #include <cstring> #include <algo…
E. Chocolate Bar time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a rectangular chocolate bar consisting of n × m single squares. You want to eat exactly k squares, so you may need…
二分查找,$set$. 对于某一次询问,如果把人删光了,那么输出$0$ $0$. 如果只剩下$1$个人,那么输出那个人喊的最低价格. 如果剩下的人数有大于等于两个, 这时最底下出现的情景必然是红色部分由一个人喊,紫色部分由另一个人喊. 这两个人分别是喊价最高价次高者和最高者,并且红色部分最后一个位置的下一个位置就是答案.因此只需在获取两个人的信息后,在最高者喊价序列中二分即可. #include<cstdio> #include<cstring> #include<vecto…
大致题意: 给出平面上n个向量,对于每个向量可以选择正的V或负的-V,求按照选择的向量走完,最后距离原点<=1.5*1e6的一个选择方案 非正解!!!!!!!!!! 先按距离原点距离由远到近贪心,贪完后答案若不满足,则进行一次dfs找出正确地路线即可(数据较水) 也可以每次每次讲向量随机排序然后贪心,直到贪到正确答案为止. #include<cstdio> #include<iostream> #include<cstring> #include<algor…
题目 传送门:QWQ A:A - Hit the Lottery 分析: 大水题 模拟 代码: #include <bits/stdc++.h> using namespace std; int main(){ int n; ;scanf("%d",&n); ){ x++; n-=; } ){ x++; n-=; } ){ x++; n-=; } ){ x++; n-=; } printf("%d\n",x+n); } B:B - World C…
CodeForces 749D. Leaving Auction 传送门 There are n people taking part in auction today. The rules of auction are classical. There were n bids made, though it's not guaranteed they were from different people. It might happen that some people made no bid…
2013. Neither shaken nor stirred Time limit: 1.0 secondMemory limit: 64 MB The ACM ICPC regional contest in St. Petersburg is a stressful event even for veterans of competetive programming. That’s why for the last four years programmer Denchik and hi…
E. Chocolate Bar Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/problem/E Description You have a rectangular chocolate bar consisting of n × m single squares. You want to eat exactly k squares, so you may need to break…
C. Graph Reconstruction Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/329/problem/C Description I have an undirected graph consisting of n nodes, numbered 1 through n. Each node has at most two incident edges. For each pa…
Adieu l'ami. Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around the abandoned Eikou Cram School building, Oshino's makeshift residence. The space is represented by a rectangular grid of n × m cells, arranged into n…
题目链接:http://codeforces.com/contest/598/problem/E E. Chocolate Bar time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a rectangular chocolate bar consisting of n × m single squares. Y…
E. Alyona and Triangles 题目连接: http://codeforces.com/contest/682/problem/E Description You are given n points with integer coordinates on the plane. Points are given in a way such that there is no triangle, formed by any three of these n points, which…
http://codeforces.com/contest/749/problem/D 题意:有几个人在拍卖场竞价,一共有n次喊价,有q个询问,每一个询问有一个num,接下来num个人从这次拍卖中除去,问对于每一个询问减掉num个人后是谁赢了拍卖,最小的价格是多少. 思路:昨晚不会做.想法好神奇(我太弱).对于每个人用 set-S 装起来其每次喊价的下标,然后用一个数组order按价格从大到小的顺序将每个人装起来,对于每一个询问,把这num个人丢到一个 set-s 里面,然后在order里面找没…
This is an interactive problem. You are given a sorted in increasing order singly linked list. You should find the minimum integer in the list which is greater than or equal to x. More formally, there is a singly liked list built on an array of n ele…
题目链接 Mike and distribution 题目意思很简单,给出$a_{i}$和$b_{i}$,我们需要在这$n$个数中挑选最多$n/2+1$个,使得挑选出来的 $p_{1}$,$p_{2}$,$p_{3}$,...,$p_{m}$满足 $a_{p1}+a_{p2}+a_{p3}+...+a_{p_{m}}>a_{1}+a_{2}+a_{3}+...+a_{n}$ $b_{p1}+b_{p2}+b_{p3}+...+b_{p_{m}}>b_{1}+b_{2}+b_{3}+...+b_…
http://codeforces.com/gym/101341 [题意] 给定三个方阵A,B,C,问AB=C是否成立? 方阵的规模最大为1000 [思路] 求AB的时间复杂度为n*n*n,会超时 左乘一个一行n列的向量,时间复杂度降为n*n [Accepted] #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #…
[题目链接]:http://codeforces.com/problemset/problem/749/D [题意] 有n个人在竞价; 按照时间的顺序给出n次竞价(可能有一些人没有参加竞价); 每次竞价以竞价人的编号和竞价给出; 保证竞价严格递增; 且同一个人不会连续竞价两次; 现在,假设去掉某一些竞价的人; 问你最后谁是那个竞价成功的人? 如果去掉一些人之后,出现了某人连续竞价两次; 则取最小的价格(但要使得他依然能竞价成功); 每次输出winner和它的最小竞价; [题解] 每个人的有用信息…
http://codeforces.com/gym/101341/problem/I 题意:给三个N*N的矩阵,问a*b是否等于c. 思路:之前遇到过差不多的题目,当时是随机行(点),然后验证,不满足就退出.还有暴力弄的(当时的数据是500).也提到过这样的解法,当时没用这种做法做一遍. 就是构造多一个矩阵d. 由于矩阵乘法满足结合律:a * (b * d) = c * d. d是一个n*1的矩阵,b * d之后会得到一个n * 1的矩阵,因此只需要O(n^2)就可以验证是否正确. #inclu…
Codeforces 题目传送门 & 洛谷题目传送门 中考终于结束了--简单写道题恢复下状态罢. 首先这一类题目肯定没法用一般的方法解决,因此考虑用一些奇淫的乱搞做法解决这道题,不难发现,如果我们固定住了前 \(n-1\) 条边,那么第 \(n\) 条边的长度与前 \(n-1\) 条边的长度冲突的概率是小之又小了--这个用爪子想想即可明白. 因此考虑一个乱搞做法,我们每次随机前 \(n-1\) 条边的长度 \(l_1,l_2,\cdots,l_{n-1}\),然后从原点开始绕一圈每次旋转 \(\…
区间DP预处理. dp[i][j][k]表示大小为i*j的巧克力块,切出k块的最小代价. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; ; ; long long dp[maxn][maxn][maxn]; int n,m,k; void f() { ;i<=;i++) { ;j<=;j++) { ;k<…
大意: 若干个人参加拍卖会, 给定每个人出价顺序, 保证价格递增, q个询问, 给出k个人的编号, 求删除这k个人的所有出价后, 最终谁赢, 他最少出价多少. set维护每个人最后一次投票的时间, 每次询问直接暴力找到最后一个未删除的, 假设为$x$, 那么$x$就是最后赢家, 求最少出价的话, 只要$x$的出价大于$x$之前一位的最大出价即可. #include <iostream> #include <sstream> #include <algorithm> #i…
D. Phillip and Trains time limit per test: 1 second memory limit per test :256 megabytes input: standard input output :standard output The mobile application store has a new game called "Subway Roller". The protagonist of the game Philip is loca…
Like many of you, I have been very busy upgrading my apps to make them fit for iOS 7. The latest version of iOS introduces lots of visual changes. From a developer’s perspective, the navigation bar and status bar are two noticeable changes that need…
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…