题目连接

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

做法: 直接模拟

#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. php开启ssl支持

    1.首先在php的安装文件下找到三个文件 并copy到系统目标下的 system32文件夹下: ssleay32.dll.libeay32.dll,php_openssl.dll. 2.打开php.i ...

  2. qDebug 学习小结

    在qtcentre中看到有网友问这样一个问题: Why this doesn't work? qDebug() << "Test" << std::endl ...

  3. js正则表达式中的问号使用技巧总结

    这篇文章主要介绍了js正则表达式中的问号几种用法,比如+?,*?,{2,3}?可以停止匹配的贪婪模式等例子的解析. 在表示重复的字符后面加问号,比如+?,*?,{2,3}?可以停止匹配的贪婪模式. v ...

  4. JAVA try-catch-finally-return

      正常执行流程: try执行,遇到异常就跳到catch执行(以使得程序不会崩溃): 不管有没有异常catch,最后都执行finally   含return语句执行流程分析: 若try块中return ...

  5. nyoj 623

    #include <iostream> using namespace std; int main() { int a[51][51],b[51][51],c[51][51],i,j,k, ...

  6. (转)jQuery LigerUI 插件介绍及使用之ligerTree

    一,简介  ligerTree的功能列表: 1,支持本地数据和服务器数据(配置data或者url) 2,支持原生html生成Tree 3,支持动态获取增加/修改/删除节点 4,支持大部分常见的事件 5 ...

  7. SQL Server 和CLR集成

    通过在 Microsoft SQL Server 中托管 CLR(称为 CLR 集成),可以在托管代码中编写存储过程.触发器.用户定义函数.用户定义类型和用户定义聚合函数. 因为托管代码在执行之前会编 ...

  8. 如何搭建DHCP及DHCP中继服务器

    当局域网中有大量的主机时,如果逐台设置ip地址.默认网关.dns服务器地址时等网络参数,显然是一个费力也未必讨好的方法,这时使用DHCP的方式分发ip地址,能够动态配置各客户机的网络地址参数,大大减轻 ...

  9. mysql文件导入到数据库load data infile into table 的使用例子

    load data infile "C:/Users/Administrator/Desktop/1.txt"into table 要一个已经存的表名 字段默认用制表符隔开 文件 ...

  10. mvvm框架正式名字确定

    经过长时间的选名,今天终于把名字定下来了,ddrjs  data drive render,其实框架的核心还是 数据驱动渲染,其实现在市面上的大部分mvvm框架如:angular.vue.avalon ...