The 2014 ACMICPC Asia Regional Beijing Online
【C】-_-///不懂
【D】数论,概率密度
【H】区间维护+线段树+DFS序(可以看看)
【I】BFS地图题(当时好多人坑在摄像头上面了,现在有一点点思路,分层图,一会看看)
【J】-_-/////
貌似除了这两题巨坑的,剩下的都有能出的可能性
【A】
Always Cook Mushroom
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
【Sample Output】
Case #: Case #:
【题意】 给出一张最大1000*1000的图,给出一些询问,每次询问给出一个斜率和x,要求三角内的所有点的和。
【分析】
题目意思比较裸,直观地想到这道题目的难度肯定不是在理解上,应该是数据比较大太裸的算法不可能卡过。
果然试了各种,唯一想到的树状数组也加上去了,还是一直TLE没能在比赛过程中出解。
赛后整理终于明白了,这道题目的关键在于如何把一张二维的图转化为一维来解决,本题给我的启发是:累加的题目如果要避免反复加引起的重复的话,树状数组是必须的,时间非常优秀,然而树状数组毕竟是一维的,必须想到办法解决二维压成一维之后的后效性等等问题才能发挥出最大的效果。
最后的算法:
二维转一维:将最大1000*1000个点按照斜率排序。对于每次的询问也是按照斜率排序。
想象有一根轴,从x轴的0°角开始逆时针扫整个平面,扫到的点按照x坐标加入树状数组,直到扫到与一条询问线重合,则对该次询问求sum(x)。这样就能避免了重复操作。把结果按照原始顺序重新输出即可。
/* ***********************************************
MYID : Chen Fan
LANG : G++
PROG : HDU5032
************************************************ */ #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; long long c[];
int outp[];
long long ou[]; typedef struct poin
{
int x,y;
long long v;
double ang;
} point; point poi[];
int totp; typedef struct nod
{
int a,b,x,src;
double ang;
} node; node lis[]; bool op1(point a,point b)
{
if (a.ang==b.ang) return a.x<b.x;
else return a.ang<b.ang;
} bool op2(node a,node b)
{
if (a.ang==b.ang) return a.a<b.a;
else return a.ang<b.ang;
} int lowbit(int s)
{
return s&-s;
} void update(int s,long long x)
{
while (s<=)
{
c[s]+=x;
s+=lowbit(s);
}
} long long sum(int s)
{
long long t=;
while (s>)
{
t+=c[s];
s-=lowbit(s);
}
return t;
} int main()
{
freopen("test.txt","r",stdin); int t; totp=;
for (int i=;i<=;i++)
for (int j=;j<=;j++)
{
totp++;
poi[totp].x=i;
poi[totp].y=j;
poi[totp].ang=(double)j/i;
}
sort(&poi[],&poi[+totp],op1); scanf("%d",&t);
for (int tt=;tt<=t;tt++)
{
int A,B;
scanf("%d%d",&A,&B);
memset(c,,sizeof(c)); for (int i=;i<=totp;i++) poi[i].v=(poi[i].x+A)*(poi[i].y+B); printf("Case #%d:\n",tt); int m;
scanf("%d",&m);
for (int i=;i<=m;i++)
{
scanf("%d%d%d",&lis[i].a,&lis[i].b,&lis[i].x);
lis[i].ang=(double)lis[i].b/lis[i].a;
lis[i].src=i;
}
sort(&lis[],&lis[+m],op2);
for (int i=;i<=m;i++) outp[lis[i].src]=i; for (int i=,j=;i<=m;i++)
{
while (j<=totp&&lis[i].ang-poi[j].ang>=)
{
update(poi[j].x,poi[j].v);
j++;
}
ou[i]=sum(lis[i].x);
} for (int i=;i<=m;i++) printf("%lld\n",ou[outp[i]]);
} return ;
}
【启发】
既然已经想到了树状数组,就应该多想想树状数组的性质,本题是利用了极角的特性二维化一维,思维上非常地巧妙。
树状数组这一块另外再补补,尤其是多维的情况
【B】
Building
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Special Judge
【Sample Output】
Case #:
101.3099324740
Case #:
90.0000000000
Case #:
78.6900675260
【说明】
不太擅长几何题,好在队友给力能解决,日后慢慢看......0.0,嘿嘿
【E】
Explosion
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total
In the first line of each test case, there is an integer N (N<=1000) indicating the number of rooms.
The following N lines corresponde to the rooms from 1 to N. Each line begins with an integer k (0<=k<=N) indicating the number of keys behind the door. Then k integers follow corresponding to the rooms these keys can open.
【Sample Output】
Case #: 1.00000
Case #: 3.00000
【题意】
/* ***********************************************
MYID : Chen Fan
LANG : G++
PROG : HDU5036
************************************************ */ #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset> using namespace std; bitset<> a[]; int main()
{
int t;
scanf("%d",&t);
for (int tt=;tt<=t;tt++)
{
int n;
scanf("%d",&n);
for (int i=;i<=n;i++)
{
a[i].reset();
a[i][i]=true;
} for (int i=;i<=n;i++)
{
int m;
scanf("%d",&m);
for (int j=;j<=m;j++)
{
int k;
scanf("%d",&k);
a[i][k]=true;
}
} for (int i=;i<=n;i++)
for (int j=;j<=n;j++)
if (a[j][i]) a[j]|=a[i]; double ans=;
for (int i=;i<=n;i++)
{
int tot=;
for (int j=;j<=n;j++)
if (a[j][i]) tot++;
ans+=1.0/tot;
} printf("Case #%d: %.5lf\n",tt,ans);
} return ;
}
有关bitset的用法,详见另外整理的一篇博文:
http://www.cnblogs.com/jcf94/p/3997908.html
【F】
Frog
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
The river could be considered as an axis.Matt is standing on the left bank now (at position 0). He wants to cross the river, reach the right bank (at position M). But Matt could only jump for at most L units, for example from 0 to L.
As the God of Nature, you must save this poor frog.There are N rocks lying in the river initially. The size of the rock is negligible. So it can be indicated by a point in the axis. Matt can jump to or from a rock as well as the bank.
You don't want to make the things that easy. So you will put some new rocks into the river such that Matt could jump over the river in maximal steps.And you don't care the number of rocks you add since you are the God.
Note that Matt is so clever that he always choose the optimal way after you put down all the rocks.
For each test case, the first line contains N, M, L (0<=N<=2*10^5,1<=M<=10^9, 1<=L<=10^9).
And in the following N lines, each line contains one integer within (0, M) indicating the position of rock.
【Sample Output】
Case #:
Case #:
【题意】
【分析】
【G】
Grade
Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
The first line of each test cases contains one integers N (1<=N<=10^6),denoting the number of the mushroom.
The second line contains N integers, denoting the weight of each mushroom. The weight is greater than 0, and less than 200.
The first line contains "Case #x:", where x is the case number (starting from 1)
The second line contains the mode of the grade of the given mushrooms. If there exists multiple modes, output them in ascending order. If there exists no mode, output “Bad Mushroom”.
【Sample Output】
Case #: Case #:
Bad Mushroom
Case #:
【分析】
排序+判断,有些细节上的小问题要多注意一下
The 2014 ACMICPC Asia Regional Beijing Online的更多相关文章
- The 2014 ACM-ICPC Asia Regional Anshan
继续复盘下一场Regional! [A]-_-/// [B]模拟(之前每次遇到模拟.暴搜都直接跳了,题目太长也是一个原因...下次是在不行可以尝试一下) [C]数论 互质.容斥? [D]数学推导(方差 ...
- The 2014 ACMICPC Asia Regional Xian
2题继续遗憾收场,每次都是只差最后一步.这一场却是之前那么多场中感觉距离奖牌最近的时候.好好总结一下经验教训,复盘之后好好准备下一场北京的最后一战吧. 一开始的状态非常不错,10分钟跟榜完成1A,第二 ...
- The 2014 ACMICPC Asia Regional Shanghai Online
XorZip小队第一次合作,虽然结果还是有些可惜,但是状态和感觉都还不错. [A]数论+二分(-_-///) [B]Lucas定理+数位DP(-_-///) [C]LCA.LCT+树链剖分 [D]题目 ...
- The 2014 ACMICPC Asia Regional Guangzhou Online
[A]-_-/// [B]线段树+位运算(感觉可出) [C]地图BFS,找最长线 [D]地图BFS,加上各种复杂情况的最短路-_- [E]-_-/// [F]三分+圆与线段的交点,计算几何 [G]-_ ...
- The 2014 ACMICPC Asia Regional Xian Online
[A]签到题 [B]后缀数组 [C]染色,DP(感觉可出) [D]BFS搜索,有点麻烦 [E]博弈论,Nim博弈 [F]BFS状态搜索 [G]概率DP+状态压缩 [H]异或+构造 [I]矩阵快速幂(队 ...
- The 2014 ACM-ICPC Asia Regional Anshan Online
[A]无向图的双联通子图计数.DP+状态压缩 [B]计算几何(点的旋转) [C]DP+状态压缩 [D]离散数学+DP (感觉可出) [E]概率DP [F]LCT模板题(-_-///LCT是啥!!!!) ...
- ZOJ 3811 Untrusted Patrol The 2014 ACM-ICPC Asia Mudanjiang Regional First Round
Description Edward is a rich man. He owns a large factory for health drink production. As a matter o ...
- The 2014 ACM-ICPC Asia Mudanjiang Regional Contest
The 2014 ACM-ICPC Asia Mudanjiang Regional Contest A.Average Score B.Building Fire Stations C.Card G ...
- The 2014 ACM-ICPC Asia Mudanjiang Regional Contest(2014牡丹江区域赛)
The 2014 ACM-ICPC Asia Mudanjiang Regional Contest 题目链接 没去现场.做的网络同步赛.感觉还能够,搞了6题 A:这是签到题,对于A堆除掉.假设没剩余 ...
随机推荐
- u盘烧写后实际容量变小了
百度了一下 : http://jingyan.baidu.com/article/d45ad148f383ea69552b808a.html 百度下载 USBoot 打开软件 列表中选择你的U盘,点击 ...
- SQL 优化案例 1
create or replace procedure SP_GET_NEWEST_CAPTCHA( v_ACCOUNT_ID in VARCHAR2, --接收短信的手机号 v_Tail_num i ...
- 我眼中的C#3.0 摘自于网络:http://www.cnblogs.com/joinger/articles/1297237.html
每次有新技术发布时,我们总能感受到两种截然不同的情绪: 一种是恐惧和抵抗,伴随着这种情绪的还有诸如"C# 2.0用的挺好的,为什么要在C# 3.0搞到那么复杂?"或者"我 ...
- SEO策略与细节:细节决定成败
昨天展开seo探讨会.听了一场医疗界seo大神的讲座.收益匪浅今天讲他的演讲内容整理出来与大家分享.希望对医疗界的seo带来些帮助.站长们一起成长! 一.首页 1.元标签设置 标题:上海癫痫病医院哪家 ...
- 用PHP实现验证码功能
目前,不少网站为了防止用户利用机器人自动注册.登录.灌水,都采用了 验证码技术.所谓验证码,就是将一串随机产生的数字或符号,生成一幅图片, 图片里加上一些干扰象素(防止OCR),由用户肉眼识别其中的验 ...
- linux视频学习3(linux安装,shell,tcp/ip协议,网络配置)
linux系统的安装: 1.linux系统的安装方式三种: 1.独立安装linux系统. 2.虚拟机安装linux系统. a.安装虚拟机,基本是一路点下去. b.安装linux. c.linux 安装 ...
- java 反射的实例
JAVA反射机制是在运行状态中,对于任意一个类,都能够得到这个类的所有属性和方法;对于任意一个对象,都能够调用它的任意一个方法;这种动态获取的信息以及动态调用对象的方法的功能称为java语言的反射机制 ...
- Singleton ——运行时全局唯一对象
Singleton 运行时全局唯一对象 Singleton模式只解决一个问题,如何做到运行时创建一个全局唯一的对象? 1:隐藏类的实例化操作,即将构造函数声明为private或protected.任何 ...
- 使用HttpUtils 上传视频文件
private void shangchuan(){ //文件的路径 //File file=new File(path); File fi ...
- hbase建索引的两种方式
转载自http://blog.csdn.net/ryantotti/article/details/13295325 在二级索引的实现技术上一般有几个方案: 1. 表索引 使用单独的hbas ...