Google Code Jam 2012 round 2 problem A: Swinging Wild
题意:你要从起点经过绳子荡到终点,每次你必须抓住另一个绳子,在空中不能向下爬。问是否有合理的方案
做法: 直接模拟
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <functional>
#include <cmath>
#include <stack>
typedef long long ll;
using namespace std;
int n,t,D;
int l[10001],d[10001];
struct st
{
int l;
int d;
st(int a,int b){
this->l = a;
this->d = b;
}
};
int main(){
freopen("in.txt","r",stdin);
freopen("out2.txt","w",stdout);
ios::sync_with_stdio(0);
cin>>t;
int cs = 0;
while(cs<t){
cin>>n;
for(int i=0;i<n;i++)
cin>>l[i]>>d[i];
cin>>D;
bool ok = false;
stack<st> qu;
vector<bool> inqu(n);
qu.push(st(0,l[0]));
inqu[0] = true;
while(!qu.empty()){
st cur = qu.top();
qu.pop();
if ( l[cur.l]+cur.d>=D)
{
ok = true;
break;
}
for(int i=cur.l+1;i<n;i++){
if(l[cur.l]+cur.d>=l[i]){
if(!inqu[i]){
qu.push(st(i,min(d[i],l[i]-l[cur.l])));
inqu[i] = true;
} }else{
break;
}
}
}
cout<<"Case #"<<++cs<<": "<<(ok?"YES":"NO")<<endl;
}
}
Google Code Jam 2012 round 2 problem A: Swinging Wild的更多相关文章
- Google Code Jam 2010 Round 1C Problem A. Rope Intranet
Google Code Jam 2010 Round 1C Problem A. Rope Intranet https://code.google.com/codejam/contest/61910 ...
- Google Code Jam 2010 Round 1C Problem B. Load Testing
https://code.google.com/codejam/contest/619102/dashboard#s=p1&a=1 Problem Now that you have won ...
- dp - Google Code jam Qualification Round 2015 --- Problem B. Infinite House of Pancakes
Problem B. Infinite House of Pancakes Problem's Link: https://code.google.com/codejam/contest/6224 ...
- Google Code jam Qualification Round 2015 --- Problem A. Standing Ovation
Problem A. Standing Ovation Problem's Link: https://code.google.com/codejam/contest/6224486/dashbo ...
- Google Code Jam 2010 Round 1A Problem A. Rotate
https://code.google.com/codejam/contest/544101/dashboard#s=p0 Problem In the exciting game of Jo ...
- Google Code Jam 2010 Round 1B Problem B. Picking Up Chicks
https://code.google.com/codejam/contest/635101/dashboard#s=p1 Problem A flock of chickens are runn ...
- Google Code Jam 2010 Round 1B Problem A. File Fix-it
https://code.google.com/codejam/contest/635101/dashboard#s=p0 Problem On Unix computers, data is s ...
- Google Code Jam 2016 Round 1B Problem C. Technobabble
题目链接:https://code.google.com/codejam/contest/11254486/dashboard#s=p2 大意是教授的学生每个人在纸条上写一个自己的topic,每个to ...
- Google Code Jam 2014 Round 1B Problem B
二进制数位DP,涉及到数字的按位与操作. 查看官方解题报告 #include <cstdio> #include <cstdlib> #include <cstring& ...
随机推荐
- android实现界面左右滑动(GridView动态设置item,支持每个item按某个属性排序来显示在不同的界面)
效果图 : 分别是第一页.第二页.第三页,随手截的图,不整齐,勿见怪.开始走了弯路,废了不少时间. 思路如下: 1.用ViewPager实现左右分页滑动 ...
- C#视频总结
C#视频利用了四天看完了,由于有VB的基础.所以看起来并没有感觉太吃力.在主要的数据类型.运算之间没有多大的差别. 在循环控制语句上也就是大同小异.在类.继承和多态方面可能有一些陌生,可是经过了前期的 ...
- HDU -1284钱币兑换
这个是完全背包的基础题, 模拟换钱, 刚开始状态方程写错了,我直接写dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3], 然后想了想感觉太大了,不太对,后来看网上的代码 ...
- ASP.NET-FineUI开发实践-4
最近实在没时间研究东西,FineUI一直也没进一步实践,但是还是很想学点东西,所以找了个课题研究了下,在论坛里看见了又下角的提醒,自己想了想做了一个,我不是大神,接触EXTJS很少,就是用到哪看哪,没 ...
- java反射机制 struts2 获取 action、method、invocation、proxy
ActionInvocation invocation = ActionContext.getContext().getActionInvocation(); Object action = invo ...
- css新增属性
圆角,border-radius: 1-4个数字/1-4个数字,前面是水平,后面是垂直,不给“/”表示水平和垂直一样,举例如下: <head> <meta http-equiv=&q ...
- mongodb的副本集总结
主节点A.备份节点B.仲裁者C.是否真的需求仲裁者? 需要. 怎样才算大多数表格如下: 怎样才算大多数表格 副本集中的成员总数 副本集中的大多数 1 1 2 2 3 2 4 3 5 3 6 4 7 4 ...
- SVN版本日志对话框命令使用指南
日志使用指南 http://tortoisesvn.net/docs/nightly/TortoiseSVN_zh_CN/tsvn-dug-showlog.html
- Rolling cURL: PHP并发最佳实践
Rolling cURL: PHP并发最佳实践 在实际项目或者自己编写小工具(比如新闻聚合,商品价格监控,比价)的过程中, 通常需要从第3方网站或者API接口获取数据, 在需要处理1个URL队列时, ...
- [php基础]记录PHP错误日志 display_errors与log_errors的区别
display_errors 错误回显,一般常用语开发模式,但是很多应用在正式环境中也忘记了关闭此选项.错误回显可以暴露出非常多的敏感信息,为攻击者下一步攻击提供便利.推荐关闭此选项. display ...