[BZOJ2298]problem a】的更多相关文章

Description 一次考试共有n个人参加,第i个人说:“有ai个人分数比我高,bi个人分数比我低.”问最少有几个人没有说真话(可能有相同的分数) Input 第一行一个整数n,接下来n行每行两个整数,第i+1行的两个整数分别代表ai.bi Output 一个整数,表示最少有几个人说谎 Sample Input 3 2 0 0 2 2 2 Sample Output 1 HINT 100%的数据满足: 1≤n≤100000   0≤ai.bi≤n 首先我们考虑一下,撒谎的人去哪了 然后经过周…
持续更新!! DP的难点主要分为两类,一类以状态设计为难点,一类以转移的优化为难点. DP的类型 序列DP [例题]BZOJ2298 problem a 数位DP 常用来统计或者查找一个区间满足条件的数,然后按数位顺序DO,一般需要仔细分情况讨论,常见处理如把区间拆为\([1,l),[1,r]\),记忆化,预处理等. [例题]BZOJ3131 淘金 概率DP 概率DP是对一类求时间概率或者期望概率DP的总称. 对于求概率问题,有时利用补集转化,有时将其转化为计数问题.求期望大多利用期望的线性性来…
[BZOJ2298][HAOI2011]problem a Description 一次考试共有n个人参加,第i个人说:“有ai个人分数比我高,bi个人分数比我低.”问最少有几个人没有说真话(可能有相同的分数) Input 第一行一个整数n,接下来n行每行两个整数,第i+1行的两个整数分别代表ai.bi Output 一个整数,表示最少有几个人说谎 Sample Input 3 2 0 0 2 2 2 Sample Output 1 HINT 100%的数据满足: 1≤n≤100000   0≤…
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=2298 题解:刚开始思考的方向错了...一直在想LIS什么的,又发现不合法的情况不好判断,真是个伤心的故事... 把问题转化一下,第i个人说有n-ai-bi个人和它分数一样高,那么我们就可以抽象出一条线段[a+1,n-b],它的权值为n个人中说这句话的次数和 n-ai-bi的最小值. 然后我们就将问题转化成了:给若干条线段,每条线段有一定的权值,选出若干条互不相交的线段,使得权值和最大. 感觉…
https://www.lydsy.com/JudgeOnline/problem.php?id=2298 https://www.luogu.org/problemnew/show/P2519 一次考试共有n个人参加,第i个人说:“有ai个人分数比我高,bi个人分数比我低.”问最少有几个人没有说真话(可能有相同的分数) 好题啊,以及我的dp为什么这么烂……算了吐槽放后面. 参考洛谷题解. 显然a+b+1>n一定是谎话,直接特判. 然后考虑冲突,显然两人名次相同的情况下a和b不同就说明这两人只能…
Description 一次考试共有n个人参加,第i个人说:“有ai个人分数比我高,bi个人分数比我低.”问最少有几个人没有说真话(可能有相同的分数) Input 第一行一个整数n,接下来n行每行两个整数,第i+1行的两个整数分别代表ai.bi Output 一个整数,表示最少有几个人说谎 Sample Input 3 2 0 0 2 2 2 Sample Output 1 HINT 100%的数据满足: 1≤n≤100000   0≤ai.bi≤n Source Solution a个人在他前…
题解: 虽然也是个可以过得做法...但又没有挖掘到最简单的做法... 正解是发现这个东西等价于求不相交区间个数 直接按照右端点排序,然后贪心就可以O(n)过了 而我的做法是按照a排序(其实我是在模拟这个过程但我没有发现他的本质...) 然后f[i][j]表示前i个,最大要求为j的最大值 然后用线段树来优化这个东西 一个地方存在的东西还要取个min 代码: #include <bits/stdc++.h> using namespace std; #define rint register in…
Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 1747  Solved: 876[Submit][Status][Discuss] Description 一次考试共有n个人参加,第i个人说:“有ai个人分数比我高,bi个人分数比我低.”问最少有几个人没有说真话(可能有相同的分数) Input 第一行一个整数n,接下来n行每行两个整数,第i+1行的两个整数分别代表ai.bi Output 一个整数,表示最少有几个人说谎 Sample Input…
题目 一次考试共有n个人参加,第i个人说:"有ai个人分数比我高,bi个人分数比我低."问最少有几个人没有说真话(可能有相同的分数) 输入格式 第一行一个整数n,接下来n行每行两个整数,第i+1行的两个整数分别代表ai.bi 输出格式 一个整数,表示最少有几个人说谎 输入样例 3 2 0 0 2 2 2 输出样例 1 提示 100%的数据满足: 1≤n≤100000 0≤ai.bi≤n 题解 一个人的话意思就是自己的分数排名在区间\([a_i + 1,n - b_i]\)之间,且这个区…
建模超级妙…… Description 一次考试共有n个人参加,第i个人说:“有ai个人分数比我高,bi个人分数比我低.”问最少有几个人没有说真话(可能有相同的分数) Input 第一行一个整数n,接下来n行每行两个整数,第i+1行的两个整数分别代表ai.bi Output 一个整数,表示最少有几个人说谎 Sample Input 3 2 0 0 2 2 2 Sample Output 1 HINT 100%的数据满足: 1≤n≤100000   0≤ai.bi≤n 题目分析 一开始真的真的没看…
description 一次考试共有n个人参加,第i个人说:"有ai个人分数比我高,bi个人分数比我低."问最少有几个人没有说真话(可能有相同的分数) analysis 这题转化模型很妙,容易知道最少没有说真话的数量\(=n-\)说真话最多的数量 对于\(a_i\)个比\(i\)大.\(b_i\)个比\(i\)小,可以看成\(i\)分数排名第\(a_i+1\)名 又由于有重分,那么转化成\([a_i+1,n-b_i]\)这段排名内的分数全部相等 判断某个区间单独不可行就判断\(a_i+…
problem a Description 一次考试共有n个人参加,第i个人说:"有ai个人分数比我高,bi个人分数比我低."问最少有几个人没有说真话(可能有相同的分数) Input 第一行一个整数n,接下来n行每行两个整数,第i+1行的两个整数分别代表ai.bi Output 一个整数,表示最少有几个人说谎 Sample Input 1 3 2 0 0 2 2 2 Sample Output 1 1 Hint 100%的数据满足: 1≤n≤100000 0≤ai.bi≤n Sourc…
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id=1199 Problem B: 大小关系 Time Limit: 2 Sec  Memory Limit: 128 MBSubmit: 148  Solved: 31[Submit][Status][Web Board] Description 当我们知道一组大小关系之后,可判断所有关系是否都能成立…
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem. 解决的办法是把对应的Class改成静态类.…
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 688C uDebug Description   Input   Output   Sample Input   Sample Output   Hint…
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codeschool yearly subscribed, but I have lost the track long time. I get more weight than expected. I like more and more my MacBook Pro I maybe go to the UST…
    Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and made an amazing discovery: there are only 16 types of programming contest problems! Furthermore, the top several comprise almost 80% of the problems s…
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前几项为 : 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 9694845, 35357670- 令h(0)=1,h(1)=1,catalan数满足递推式:      h(n)= h(0…
2301: [HAOI2011]Problem b Time Limit: 50 Sec  Memory Limit: 256 MBSubmit: 4032  Solved: 1817[Submit][Status][Discuss] Description 对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数. Input 第一行一个整数n,接下来n行每行五个整数,分别表示a.b.c.d.k Outp…
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactly z litres using these two jugs. If z liters of water is measurable, you must…
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the locations and height of all the buildings as shown on a cityscape photo (Figure A), write a pr…
$s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr); curl_setopt($s, CURLOPT_URL, $url); curl_setopt($s, CURLOPT_TIMEOUT, 1000); curl_setopt($s, CURLOPT_RETURNTRANSFER, 1); $body = curl_exec($s); if($…
3489: A simple rmq problem Time Limit: 40 Sec  Memory Limit: 600 MBSubmit: 1594  Solved: 520[Submit][Status][Discuss] Description 因为是OJ上的题,就简单点好了.给出一个长度为n的序列,给出M个询问:在[l,r]之间找到一个在这个区间里只出现过一次的数,并且要求找的这个数尽可能大.如果找不到这样的数,则直接输出0.我会采取一些措施强制在线. Input 第一行为两个整…
http://codeforces.com/problemset/problem/442/B (题目链接) 题意 n个人,每个人有p[i]的概率出一道题.问如何选择其中s个人使得这些人正好只出1道题的概率最大. Solution 很显然的概率dp,过了样例即可AC..话说我为什么要刷B题→_→ 代码 // codeforces442B #include<algorithm> #include<iostream> #include<cstdlib> #include<…
A^B Problem 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 Give you two numbers a and b,how to know the a^b's the last digit number.It looks so easy,but everybody is too lazy to slove this problem,so they remit to you who is wise.   输入 There are mutiple te…
A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each node has a boolean (0 or 1) labeled on it. Initially, all the labels are 0. We define this kind of operation: given a subtree, negate all its labels. An…
K - Yet Another Multiple Problem Time Limit:20000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4474 Appoint description:  System Crawler  (2014-10-16) Description There are tons of problems about integer mul…
Recently ,I got confused When I use  git to push one of my project. The problem is below: And I Found the solutions  below maybe helpful to someone who meet the problem: Dealing with non-fast-forward errors Sometimes, Git can't make your change to a…
Cisco的VPN客户端最近报"AnyConnect was not able to establish connection to the specified secure gateway." 导致连不上公司VPN了. 有人说取消共享 Problem: AnyConnect was not able to establish a connection to the specified secure gateway. Please try connecting again. Envir…
题目链接:http://poj.org/problem?id=3311 题意:一个人到一些地方送披萨,要求找到一条路径能够遍历每一个城市后返回出发点,并且路径距离最短.最后输出最短距离即可.注意:每一个地方可重复访问多次. 经典的状压dp,因为每次送外卖不超过10个地方,可以压缩. 由于题中明确说了两个城市间的直接可达路径(即不经过其它城市结点)不一定是最短路径,所以需要借助floyd首先求出任意两个城市间的最短距离. 然后,在此基础上来求出遍历各个城市后回到出发点的最短路径的距离,即求解TSP…