B. Train Seats Reservation

You are given a list of train stations, say from the station 1 to the station 100.

The passengers can order several tickets from one station to another before the train leaves the station one. We will issue one train from the station 1 to the station 100 after all reservations have been made. Write a program to determine the minimum number of seats required for all passengers so that all reservations are satisfied without any conflict.

Note that one single seat can be used by several passengers as long as there are no conflicts between them. For example, a passenger from station 1 to station 10 can share a seat with another passenger from station 30 to 60.

Input Format

Several sets of ticket reservations. The inputs are a list of integers. Within each set, the first integer (in a single line) represents the number of orders, nnn, which can be as large as 1000. After nnn, there will be nnn lines representing the nnn reservations; each line contains three integers s,t,ks, t, ks,t,k, which means that the reservation needs kkk seats from the station sss to the station ttt .These ticket reservations occur repetitively in the input as the pattern described above. An integer n=0n = 0n=0 (zero) signifies the end of input.

Output Format

For each set of ticket reservations appeared in the input, calculate the minimum number of seats required so that all reservations are satisfied without conflicts. Output a single star '*' to signify the end of outputs.

样例输入

2
1 10 8
20 50 20
3
2 30 5
20 80 20
40 90 40
0

样例输出

20
60
*

简单模拟

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/sTACK:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos[j](-1.0)
#define ei exp(1)
#define PI 3.1415926535
#define ios() ios[j]::sync_with_stdio(true)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll a[],n,s,t,w;
int main()
{
while(scanf("%lld",&n))
{
if(n==) break;
memset(a,,sizeof(a));
for(ll i=;i<n;i++)
{
scanf("%lld%lld%lld",&s,&t,&w);
for(ll j=s;j<t;j++)
{
a[j]+=w;
}
}
ll ans=;
for(ll i=;i<=;i++)
{
ans=max(ans,a[i]);
}
printf("%lld\n",ans);
}
printf("*\n");
return ;
}

F. Overlapping Rectangles

There are nnn rectangles on the plane. The problem is to find the area of the union of these rectangles. Note that these rectangles might overlap with each other, and the overlapped areas of these rectangles shall not be counted more than once. For example, given a rectangle AAA with the bottom left corner located at (0,0) and the top right corner at (2,2), and the other rectangle BBB with the bottom left corner located at (1,1) and the top right corner at (3,3), it follows that the area of the union of A and B should be7 , instead of 8.

Although the problem looks simple at the first glance, it might take a while to figure out how to do it correctly. Note that the shape of the union can be very complicated, and the intersected areas can be overlapped by more than two rectangles.

Note:

(1) The coordinates of these rectangles are given in integers. So you do not have to worry about the floating point round-off errors. However, these integers can be as large as 1,000,000.

(2) To make the problem easier, you do not have to worry about the sum of the areas exceeding the long integer precision. That is, you can assume that the total area does not result in integer overflow.

Input Format

Several sets of rectangles configurations. The inputs are a list of integers. Within each set, the first integer (in a single line) represents the number of rectangles, n, which can be as large as 1000. After n, there will be n lines representing the n rectangles; each line contains four integers <a,b,c,d> , which means that the bottom left corner of the rectangle is located at (a,b), and the top right corner of the rectangle is located at (c,d). Note that integers a, b, c, d can be as large as 1,000,000.

These configurations of rectangles occur repetitively in the input as the pattern described above. An integer n=0n = 0n=0 (zero) signifies the end of input.

Output Format

For each set of the rectangles configurations appeared in the input, calculate the total area of the union of the rectangles. Again, these rectangles might overlap each other, and the intersecting areas of these rectangles can only be counted once. Output a single star '*' to signify the end of outputs.

样例输入

2
0 0 2 2
1 1 3 3
3
0 0 1 1
2 2 3 3
4 4 5 5
0

样例输出

7
3
* 求多矩形面积,可能存在重合 扫描线
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/sTACK:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos[j](-1.0)
#define ei exp(1)
#define PI 3.1415926535
#define ios() ios[j]::sync_with_stdio(true)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
#define pr(x) cout << #x << " = " << x << " "
#define prln(x) cout << #x << " = " << x << endl
const int N = ;
int n;
struct Seg
{
double l,r,h;
int d;
Seg(){}
Seg(double l,double r,double h,int d):l(l),r(r),h(h),d(d){}
bool operator<(const Seg& rhs) const {return h<rhs.h;}
}a[N];
int cnt[N<<];
double sum[N<<],all[N];
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
void push_up(int l,int r,int rt)
{
if(cnt[rt]) sum[rt]=all[r+]-all[l];
else if(l==r) sum[rt]=;
else sum[rt]=sum[rt<<]+sum[rt<<|];
} void update(int L,int R,int v,int l,int r,int rt)
{
if(L<=l && r<=R) {
cnt[rt]+=v;
push_up(l,r,rt);
return;
}
int m = l + r >> ;
if(L<=m) update(L,R,v,lson);
if(R>m) update(L,R,v,rson);
push_up(l,r,rt);
}
int main()
{
ios_base::sync_with_stdio();
int kase = ;
while(scanf("%d",&n))
{
if(n==) break;
for(int i=;i<=n;++i)
{
double x1,y1,x2,y2;
scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
a[i]=Seg(x1,x2,y1,);
a[i+n]=Seg(x1,x2,y2,-);
all[i]=x1;all[i+n]=x2;
}
n<<=;
sort(a+, a++n);
sort(all + , all++n);
int m=unique(all+,all++n)-all-;
memset(cnt,,sizeof(cnt));
memset(sum,,sizeof(sum));
double ans=;
for(int i=;i<n;++i)
{
int l=lower_bound(all+, all++m, a[i].l)-all;
int r=lower_bound(all+, all++m, a[i].r)-all;
if(l<r) update(l,r-,a[i].d,,m,);
ans+=sum[]*(a[i+].h-a[i].h);
}
printf("%.lf\n",ans);
}
printf("*\n");
return ;
}

L. The Heaviest Non-decreasing Subsequence Problem

Let S be a sequence of integers s1s_{1}s​1​​, s2s_{2}s​2​​, ........., sns_{n}s​n​​ Each integer is is associated with a weight by the following rules:

(1) If is is negative, then its weight is 0.

(2) If is is greater than or equal to 10000, then its weight is 5. Furthermore, the real integer value of sis_{i}s​i​​ is si−10000s_{i}-10000s​i​​−10000 . For example, if sis_{i}s​i​​ is 101011010110101, then is is reset to 101101101 and its weight is 555.

(3) Otherwise, its weight is 1.

A non-decreasing subsequence of SSS is a subsequence si1s_{i1}s​i1​​, si2s_{i2}s​i2​​, ........., siks_{ik}s​ik​​, with i1<i2 ... <iki_{1}<i_{2}\ ...\ <i_{k}i​1​​<i​2​​ ... <i​k​​, such that, for all 1≤j<k1 \leq j<k1≤j<k, we have sij<sij+1s_{ij}<s_{ij+1}s​ij​​<s​ij+1​​.

A heaviest non-decreasing subsequence of SSS is a non-decreasing subsequence with the maximum sum of weights.

Write a program that reads a sequence of integers, and outputs the weight of its

heaviest non-decreasing subsequence. For example, given the following sequence:

80 75 73 93 73 73 10101 97 −1 −1 114 −1 10113 118

The heaviest non-decreasing subsequence of the sequence is <73, 73, 73, 101, 113, 118> with the total weight being 1+1+1+5+5+1=14. Therefore, your program should output 141414 in this example.

We guarantee that the length of the sequence does not exceed 2∗1052*10^{5}2∗10​5​​

Input Format

A list of integers separated by blanks:s1s_{1}s​1​​, s2s_{2}s​2​​,.........,sns_{n}s​n​​

Output Format

A positive integer that is the weight of the heaviest non-decreasing subsequence.

样例输入

80 75 73 93 73 73 10101 97 -1 -1 114 -1 10113 118

样例输出

14
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/sTACK:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos[j](-1.0)
#define ei exp(1)
#define PI 3.1415926535
#define ios() ios[j]::sync_with_stdio(true)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int dp[],a[],x;
int main()
{
int n=;
while(scanf("%d",&x)!=EOF)
{
if(x>=)
{
for(int i=;i<;i++)
a[++n]=x-;
}
else if(x>=) a[++n]=x;
}
memset(dp,,sizeof(dp));
for(int i=;i<=n;i++)
dp[upper_bound(dp,dp+,a[i])-dp]=a[i];
printf("%d\n",lower_bound(dp,dp+,INF)-dp);
return ;
}

M. Frequent Subsets Problem

Output Format

The number of α\alphaα-frequent subsets.

样例输入

15 0.4
1 8 14 4 13 2
3 7 11 6
10 8 4 2
9 3 12 7 15 2
8 3 2 4 5

样例输出

11

暴力枚举子集

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/sTACK:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos[j](-1.0)
#define ei exp(1)
#define PI 3.1415926535
#define ios() ios[j]::sync_with_stdio(true)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int n,val[],x,k;
double f;
char ch;
int main()
{
scanf("%d%lf",&n,&f);
k=;
while(~scanf("%d%c",&x,&ch))
{
val[k]+=(<<(x-));
if(ch=='\n') k++;
}
int ans=,cnt;
int pos=ceil(f*k);
for(int i=;i<(<<n);i++)
{
cnt=;
for(int j=;j<k;j++)
{
if((i&val[j])==i) printf("%d %d\n",i,val[j]),cnt++;
}
ans+=cnt>=pos?:;
}
printf("%d\n",ans);
return ;
}

2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 (B,F,L,M)的更多相关文章

  1. 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 M. Frequent Subsets Problem【状态压缩】

    2017 ACM-ICPC 亚洲区(南宁赛区)网络赛  M. Frequent Subsets Problem 题意:给定N和α还有M个U={1,2,3,...N}的子集,求子集X个数,X满足:X是U ...

  2. HDU 4046 Panda (ACM ICPC 2011北京赛区网络赛)

    HDU 4046 Panda (ACM ICPC 2011北京赛区网络赛) Panda Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: ...

  3. 2016 ACM/ICPC亚洲区青岛站现场赛(部分题解)

    摘要 本文主要列举并求解了2016 ACM/ICPC亚洲区青岛站现场赛的部分真题,着重介绍了各个题目的解题思路,结合详细的AC代码,意在熟悉青岛赛区的出题策略,以备战2018青岛站现场赛. HDU 5 ...

  4. ICPC 2018 徐州赛区网络赛

    ACM-ICPC 2018 徐州赛区网络赛  去年博客记录过这场比赛经历:该死的水题  一年过去了,不被水题卡了,但难题也没多做几道.水平微微有点长进.     D. Easy Math 题意:   ...

  5. Skiing 2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛H题(拓扑序求有向图最长路)

    参考博客(感谢博主):http://blog.csdn.net/yo_bc/article/details/77917288 题意: 给定一个有向无环图,求该图的最长路. 思路: 由于是有向无环图,所 ...

  6. [刷题]ACM/ICPC 2016北京赛站网络赛 第1题 第3题

    第一次玩ACM...有点小紧张小兴奋.这题目好难啊,只是网赛就这么难...只把最简单的两题做出来了. 题目1: 代码: //#define _ACM_ #include<iostream> ...

  7. 2016 ACM/ICPC亚洲区大连站-重现赛 解题报告

    任意门:http://acm.hdu.edu.cn/showproblem.php?pid=5979 按AC顺序: I - Convex Time limit    1000 ms Memory li ...

  8. 2014ACM/ICPC亚洲区鞍山赛区现场赛1009Osu!

    鞍山的签到题,求两点之间的距离除以时间的最大值.直接暴力过的. A - Osu! Time Limit:1000MS     Memory Limit:262144KB     64bit IO Fo ...

  9. 2017ICPC南宁赛区网络赛 Minimum Distance in a Star Graph (bfs)

    In this problem, we will define a graph called star graph, and the question is to find the minimum d ...

随机推荐

  1. 紫书 例题 11-2 UVa 1395(最大边减最小边最小的生成树)

    思路:枚举所有可能的情况. 枚举最小边, 然后不断加边, 直到联通后, 这个时候有一个生成树.这个时候,在目前这个最小边的情况可以不往后枚举了, 可以直接更新答案后break. 因为题目求最大边减最小 ...

  2. SVN学习总结(2)——SVN冲突解决

    在我们用VS进行项目合作开发的过程中,SVN的提交控制是至关重要的,大家不可避免的都遇到过SVN冲突的问题,开发的时候,应该认真学习SVN的知识,减少冲突,集中时间放在开发上. 解决冲突有三种方式: ...

  3. Camera Calibration 相机标定:Opencv应用方法

    本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/49427383 Opencv中Camer ...

  4. Redit集群搭建-Sentinel模式搭建

    Redit集群搭建 学习了: Windows:http://blog.csdn.net/mrxiagc/article/details/52799081 Linux:https://www.cnblo ...

  5. BEGINNING SHAREPOINT&#174; 2013 DEVELOPMENT 第1章节--SharePoint 2013 介绍 处理开发者需求

    BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第1章节--SharePoint 2013 介绍 处理开发者需求         SharePoint本质上是一个平台.你 ...

  6. php冒泡排序函数

    $arr=array(23,5,26,4,9,85,10,2,55,44,21,39,11,16,55,88,421,226,588); function maopao($arr,$value){// ...

  7. Linux 经常使用快捷键

    桌面下: Alt+F5   取消最大化窗体 Alt+F9   最小化窗体  Alt+F10  最大化窗体  Alt+空格 打开窗体的控制菜单 (点击窗体左上角图标出现的菜单)     ctl+r   ...

  8. Pascal Script

    MsgBox http://www.jrsoftware.org/ishelp/index.php?topic=isxfunc_msgbox ExpandConstant http://www.jrs ...

  9. hpuoj--校赛--送给新生的礼物(水题)

    问题 A: 感恩节KK专场--送给新生的礼物 时间限制: 1 Sec  内存限制: 128 MB 提交: 631  解决: 187 [提交][状态][讨论版] 题目描述 学长KK要送给学弟学妹们礼物, ...

  10. BP神经网络模型及梯度下降法

    BP(Back Propagation)网络是1985年由Rumelhart和McCelland为首的科学家小组提出,是一种按误差逆传播算法训练的多层前馈网络,是目前应用最广泛的神经网络模型之一. B ...