HDU1074 Doing Homework 状态压缩dp】的更多相关文章

Doing Homework Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3958    Accepted Submission(s): 1577 Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he has a l…
题目大意: 根据完成任务的截止时间,超时一天罚1分,求完成所有任务后的最小罚时 这里n最大为15,可以利用状态压缩来解决问题 /* 首先要明白的一点是状态1/0分别表示这件事做了还是没做 而1/0的位置表示这是哪一件事 比如说 5 可以表示为101,那么表示第一个和第三个任务已经完成 而dp[5]表示第一个和第三个任务完成所花费的最短时间 而状态5(101)是从状态1(001)或者状态4(100)转移过来的 也就是说我们总是可以通过一个较小的状态不断递推一个较大状态的dp值 dp[j] = mi…
题目大意: 有 n 项作业需要完成,每项作业有上交的期限和需完成的天数,若某项作业晚交一天则扣一分.输入每项作业时包括三部分,作业名称,上交期限,完成所需要的天数.求出完成所有作业时所扣掉的分数最少,同时输出完成作业的顺序(若有多组结果,输出按字典序排列最小的那组).(输入时,按名称的字典序输入) 思路 :题目中给出的 n 的范围很小,很明显是用状态压缩来求解.将一个整数分解成二进制形式.从左往右数起,第 i 位代表第 i 项作业的完成情况,1 代表完成,0代表未完成. #include<ios…
Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in the homework after the deadline, the teacher will reduce his score of t…
Doing Homework 题目抽象:给出n个task的name,deadline,need.  每个任务的罚时penalty=finish-deadline;   task不可以同时做.问按怎样的顺序做使得penalty最小.同时输出顺序.如果有多个满足条件的顺序,按字典序输出. #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <a…
题意:有n门课,每门课有截止时间和完成所需的时间,如果超过规定时间完成,每超过一天就会扣1分,问怎样安排做作业的顺序才能使得所扣的分最小 思路:二进制表示. #include<iostream> #include<string> #include<algorithm> #include<cstdlib> #include<cstdio> #include<set> #include<map> #include<vec…
Doing Homework Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8756    Accepted Submission(s): 4065 Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lo…
Doing Homework Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7070    Accepted Submission(s): 3104 Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lo…
题意:       给你一些作业,每个作业有自己的结束时间和花费时间,如果超过结束时间完成,一天扣一分,问你把n个作业完成最少的扣分,要求输出方案. 思路:       状态压缩dp,记录方案数的地方我用的是类似并查集的方法,记录当前状态是那个状态转移过来的,<输出的时候可以 异或 出来>,对于字典序最小,这个比较好处理,给的是升序的,所以直接更新的时候记录就行了,<如果没给可以sort下>,我是开了一个dp[i]表示i状态时的最小扣分,然后在开一个数组time[i],记录dp[i…
问题:Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in the homework after the deadline, the teacher will reduce his score o…