3296: [USACO2011 Open] Learning Languages Time Limit: 5 Sec  Memory Limit: 128 MBSubmit: 81  Solved: 39[Submit][Status] Description 农夫约翰的N(2 <= N<=10,000)头奶牛,编号为1.. N,一共会流利地使用M(1<= M <=30,000)种语言,编号从1 .. M.,第i头,会说K_i(1 <= K_i<= M)种语言,即L_…
A. Learning Languages time limit per test:2 seconds memory limit per test:256 megabytes The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered wi…
3296: [USACO2011 Open] Learning Languages Time Limit: 5 Sec  Memory Limit: 128 MBSubmit: 436  Solved: 239[Submit][Status][Discuss] Description 农夫约翰的N(2 <= N<=10,000)头奶牛,编号为1.. N,一共会流利地使用M(1<= M <=30,000)种语言,编号从1  .. M.,第i头,会说K_i(1 <= K_i<…
A. Learning Languages time limit per test:2 seconds memory limit per test:256 megabytes input standard input output standard output The "BerCorp" company has got n employees. These employees can use m approved official languages for the formal c…
C. Learning Languages 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <string> 7 #include <vector> 8 #include <stack> 9 #include <queue&…
NC25136 [USACO 2006 Ope B]Cows on a Leash 题目 题目描述 给定如图所示的若干个长条.你可以在某一行的任意两个数之间作一条竖线,从而把这个长条切开,并可能切开其他长条.问至少要切几刀才能把每一根长条都切开.样例如图需要切两刀. 注意:输入文件每行的第一个数表示开始的位置,而第二个数表示长度. 输入描述 Line \(1\) : A single integer, \(N\) (\(2 <= N <= 32000\)) Lines \(2 \cdots N…
传送门:http://www.usaco.org/index.php?page=viewproblem2&cpid=93 很容易发现,这是一个二分图的模型.竖直线是X集,水平线是Y集,若某条竖直线与水平线相交,则连边.由于目的是要没有任何两条线相交,所以二分图的边的两端不能同时取,就是要求一个二分图的最大独立集,which equals to N - 最大匹配. 然而啊然而,仍然没有一A!此题只是说给出线段两端点的坐标,并没有说x1一定<x2,y1一定<y2... 可以说这是本次月赛金…
传送门:http://www.usaco.org/index.php?page=viewproblem2&cpid=91 这一题我很快的想出了,把>= x的值改为1,< x的改为-1,这样,某一段连续区间的和若非负,则这段区间符合题意.我连这个都想到了却没想到要去求逆序对!!!天呐,我真是太迷了!! 前缀和+逆序对. 逆序对就不解释了,该归并的归并,Fenwick Tree的Fenwick Tree,但是对于此题有一个O(n)的算法,仅限于求此题的逆序对!鉴于这一题值域范围小,而且相邻…
题目大意: 输入n k,1-n的排列,k次操作 操作P:输入一个m 输出第m个排列 操作Q:输入一个排列 输出它是第几个排列 Sample Input 5 2P3Q1 2 5 3 4 Sample Output 1 2 4 3 55   康拓展开裸题 然而因为用了getchar(); 所以一直在超时 康拓展开:http://www.cnblogs.com/dong008259/archive/2011/12/12/2283436.html #include <bits/stdc++.h> us…
题意抽象出来就是求联通块的个数吧,然后添加最少边使图联通. 注意所有人都不会任何语言的时候,答案是n而不是n-1. #include<algorithm> #include<iostream> #include<cstring> #include<fstream> #include<sstream> #include<vector> #include<string> #include<cstdio> #incl…