Selecting Courses(POJ-2239)

Problem Description

It is well known that it is not easy to select courses in the college, for there is usually conflict among the time of the courses. Li Ming is a student who loves study every much, and at the beginning of each term, he always wants to select courses as more as possible. Of course there should be no conflict among the courses he selects. 

There are 12 classes every day, and 7 days every week. There are hundreds of courses in the college, and teaching a course needs one class each week. To give students more convenience, though teaching a course needs only one class, a course will be taught several times in a week. For example, a course may be taught both at the 7-th class on Tuesday and 12-th class on Wednesday, you should assume that there is no difference between the two classes, and that students can select any class to go. At the different weeks, a student can even go to different class as his wish. Because there are so many courses in the college, selecting courses is not an easy job for Li Ming. As his good friends, can you help him?

Input

The input contains several cases. For each case, the first line contains an integer n (1 <= n <= 300), the number of courses in Li Ming's college. The following n lines represent n different courses. In each line, the first number is an integer t (1 <= t <= 7*12), the different time when students can go to study the course. Then come t pairs of integers p (1 <= p <= 7) and q (1 <= q <= 12), which mean that the course will be taught at the q-th class on the p-th day of a week.

Output

For each test case, output one integer, which is the maximum number of courses Li Ming can select.

Sample Input

5
1 1 1
2 1 1 2 2
1 2 2
2 3 2 3 3
1 3 3

Sample Output

4

题意:规定每周每天有 12 节课,先给出 n 个课程,以及这 n 个课程在第 p 天的第 q 节上,如果几个课都在同一天的同一节上,那么需要选择其中一个,不能选择多个课程,求一周最多能上几节课

思路:将 n 节课看成左边的点集,将每周 7*12=84 节课看成右边的点集,即为一个二分图,根据题意,现在要选出最多的点对,使得左边的点尽可能的与右边匹配,即为二分图的最大匹配问题

Source Program

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define PI acos(-1.0)
#define E 1e-6
#define MOD 16007
#define INF 0x3f3f3f3f
#define N 10001
#define LL long long
using namespace std;
bool vis[N];
int link[N];
vector<int> G[N];
bool dfs(int x){
    for(int i=0;i<G[x].size();i++){
        int y=G[x][i];
        if(!vis[y]){
            vis[y]=true;
            if(link[y]==-1 || dfs(link[y])){
                link[y]=x;
                return true;
            }
        }
    }
    return false;
}
int hungarian(int n)
{
    int ans=0;
    for(int i=1;i<=n;i++){
        memset(vis,false,sizeof(vis));
        if(dfs(i))
            ans++;
    }
    return ans;
}
int main(){
    int n;
    while(scanf("%d",&n)!=EOF&&n){
        memset(link,-1,sizeof(link));
        for(int i=0;i<N;i++)
            G[i].clear();

        for(int i=1;i<=n;i++){
            int num;
            scanf("%d",&num);
            while(num--){
                int p,q;
                scanf("%d%d",&p,&q);
                G[i].push_back( (p-1)*12+q );
            }
        }
        printf("%d\n",hungarian(n));

    }
    return 0;
}

 

<think>好的,用户想知道为什么在ACPI开发中选择'acpica-tools'而不是'iasl',以及它们的区别。首先,我需要确认这两个工具的关系和各自的功能。 记得之前了解过,ACPI相关工具有IASL(Intel ASL编译器),它主要用于编译ASL代码到AML。而acpica-tools可能是一个工具集,包含IASL和其他工具。需要验证这一点。 查找资料发现,acpica-tools是ACPICA项目提供的工具集合,包括iasl编译器以及其他实用程序,比如acpiexec、acpidump等。而单独的iasl可能只是其中的编译器部分。因此,选择acpica-tools可能是因为需要更全面的工具支持,而不仅仅是编译功能。 另外,用户可能在开发过程中需要调试、反编译或分析ACPI表,这时候acpica-tools提供的其他工具就显得必要了。比如,acpiexec用于模拟执行AML代码,acpidump用于提取系统ACPI表,这些在单独使用iasl时可能无法实现。 还需要考虑不同Linux发行版的软件包管理情况。例如,在Debian/Ubuntu中,安装acpica-tools会包含iasl,而单独安装iasl可能版本较旧或者功能不全。因此,推荐使用acpica-tools以获得最新和全面的工具支持。 总结一下,区别在于acpica-tools是一个综合工具包,而iasl是其中的编译器。选择前者可以提供更完整的开发环境,适合需要多种工具配合的场景。而如果仅需编译ASL代码,单独使用iasl可能足够。</think>在ACPI开发中选择`acpica-tools`还是`iasl`,主要取决于开发需求和工作流程。以下是两者的区别与选择建议: ### 1. **工具定位与功能范围** - **`iasl`** 是Intel ACPI编译器(Intel ACPI Source Language Compiler)的独立版本,核心功能是将ASL(ACPI Source Language)代码编译为AML(ACPI Machine Language)字节码。它是ACPI开发中**最基础的编译工具**,适用于仅需完成源码到二进制转换的场景。 - **`acpica-tools`** 是ACPICA项目提供的**完整工具套件**,包含以下组件: - `iasl`:编译器(支持ASL到AML的编译和AML反编译为ASL) - `acpiexec`:AML模拟执行器,用于调试ACPI代码 - `acpidump`:提取系统ACPI表的工具 - `acpixtract`:从系统转储中分离单个ACPI表 因此,`acpica-tools`不仅覆盖编译需求,还提供**调试、分析和逆向工程**的支持[^2][^3]。 ### 2. **版本更新与兼容性** - **`iasl`独立版本** 可能滞后于ACPICA项目的主线更新,尤其是通过Linux发行版仓库安装时(如`apt install iasl`)。例如,Ubuntu 22.04默认仓库的`iasl`版本为20200925,而截至2023年ACPICA已更新至20230628。**旧版本可能缺少对新语法或ACPI规范的支持**。 - **`acpica-tools`** 通过官方渠道(如ACPICA官网或GitHub)获取时,通常包含最新功能和对ACPI 6.x规范的完整支持,适合需要**兼容最新硬件或调试复杂ACPI行为**的场景[^1]。 ### 3. **典型使用场景** - **选择`iasl`的场合** - 仅需快速编译ASL代码(如修改DSDT/SSDT表) - 嵌入式环境中资源受限,需最小化工具体积 - **选择`acpica-tools`的场合** - 需要**调试AML代码**(如通过`acpiexec`模拟执行并跟踪ACPI方法) - 需要**逆向分析**系统ACPI表(如使用`acpidump`提取表后,用`iasl -d`反编译为ASL) - 需要验证ACPI代码是否符合规范(如通过`acpihelp`查询ACPI对象定义) ### 4. **安装与使用示例** - **安装`acpica-tools`(推荐方式)** ```bash # Debian/Ubuntu sudo apt install acpica-tools # 或从源码编译最
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值