题目连接

题意:你要从起点经过绳子荡到终点,每次你必须抓住另一个绳子,在空中不能向下爬。问是否有合理的方案

做法: 直接模拟

#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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. Google Code Jam 2016 Round 1B Problem C. Technobabble

    题目链接:https://code.google.com/codejam/contest/11254486/dashboard#s=p2 大意是教授的学生每个人在纸条上写一个自己的topic,每个to ...

  9. Google Code Jam 2014 Round 1B Problem B

    二进制数位DP,涉及到数字的按位与操作. 查看官方解题报告 #include <cstdio> #include <cstdlib> #include <cstring& ...

随机推荐

  1. uva 10555 - Dead Fraction)(数论)

    option=com_onlinejudge&Itemid=8&category=516&page=show_problem&problem=1496" st ...

  2. Java基础知识强化之IO流笔记03:throws的方式处理异常

    1. 什么时候使用throws ? (1)定义功能方法时候,需要把出现的问题暴露出来,让调用者去处理.那么就通过throws在方法上标识. (2)有时候,我们是可以对异常进行处理的,但是又有些时候,我 ...

  3. Java基础知识强化72:正则表达式之判断功能(手机号码判断 和 校验邮箱)

    1.  判断功能: 使用了String类的matches方法,如下: public boolean matches(String regex): 2. 判断手机号码的案例: package cn.it ...

  4. URAL 1306 - Sequence Median 小内存求中位数

    [题意]给出n(1~250000)个数(int以内),求中位数 [题解]一开始直接sort,发现MLE,才发现内存限制1024k,那么就不能开int[250000]的数组了(4*250000=1,00 ...

  5. 计算方法(一)用C#实现数值迭代

    平时,经常会遇到解方程,计算方法中常用的有二分法(精度太低,迭代次数多,一般没人用),牛顿迭代法,弦截法,网上大多都是C++或者Java的实现代码,很少有C#的,我在本科毕业论文中用到了这些,那时也需 ...

  6. mui实现退出当前应用

    var first = null; var showMenu = false; mui.back = function() { if(showMenu) { closeMenu();} else { ...

  7. 去掉input【type=number】默认的上下箭头

    input::-webkit-inner-spin-button {-webkit-appearance: none;}input::-webkit-outer-spin-button {-webki ...

  8. 启动mySQL安装出现1067错误

    可能几种的办法: 删除data目录下的ib_logfile0和ib_logfile1 查看my.ini文件中的dir设置 查看err文件,如果是temp出现错误文件,则添加temp文件的路径

  9. swing——JFrame基本操作

    用JFrame(String String1)创建一个窗口 public void setBounds(int a,int b,int width,int height)设置窗口初始化的位置(a,b) ...

  10. Secure CRT 如何连接虚拟机里面的CentOS系统 当主机使用有线网的时候 作者原创 欢迎转载

    1.虚拟机的网卡配置如下图所示: 2.在CentOS 5.8的命令行界面:输入如下指令 然后准备修改里面的网关地址和自己的IP地址 3.同时查看自己的IP地址和网关 4.在第二步里面修改,网关地址应该 ...