题目连接

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

做法: 直接模拟

#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. Activity启动机制

    以下资料摘录整理自老罗的Android之旅博客,是对老罗的博客关于Android底层原理的一个抽象的知识概括总结(如有错误欢迎指出)(侵删):http://blog.csdn.net/luosheng ...

  2. knockout --- foreach -- 前端必备

    很久很久没写博客了,丫的,节操掉一地了,颓废了,惭愧. 很久很久没有弄 knouckout.js 了,今天重新操作,蛋疼啊,忘记得差不多了,于是只好硬着头皮再去看官网,于是,feel慢慢回来了. 本来 ...

  3. Android Activity间传值

    Android中不同的Activity之间的传值方式(Main为当前Activity,Login为目标Activity) 1.使用Intent Intent intent = new Intent(M ...

  4. Android学习笔记:如何设置ImageView中图片的显示方式

    我们在用ImageView显示图片时,很多情况下图片的大小与ImageView的尺寸不是完全一样的.这时就涉及到该如何设置显示图片了. ImageView有个重要的属性是ScaleType,该属性用以 ...

  5. MTK Android 默认值修改笔记

    1.设置菜单: 1.1位置信息(Location)默认关闭: 请将 alps\frameworks\base\packages\SettingsProvider\res\values\default. ...

  6. Android开发手记(14) 使用MediaPlayer播放mp3

    1.获取MediaPlayer实例 (1)可以直接通过new或者create方式: 调用setDataSource和create的区别是,create时已经执行了MediaPlayer.prepare ...

  7. Oracle数据库名、实例名、数据库域名、全局数据库名、服务名之间的区别

    数据库名.实例名.数据库域名.全局数据库名.服务名 这是几个令很多初学者容易混淆的概念.相信很多初学者都与我一样被标题上这些个概念搞得一头雾水.我们现在就来把它们弄个明白. 一.数据库名 什么是数据库 ...

  8. RTSP协议资料

    维基百科: RTSP:http://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol RTP:http://en.wikipedia.org/wik ...

  9. iOS判断当前控制器是否正在显示

    +(BOOL)isCurrentViewControllerVisible:(UIViewController *)viewController { return (viewController.is ...

  10. Swift - 36 - 结尾闭包(Trailing closure)和捕获数值(Capturing Values)的简单介绍

    //: Playground - noun: a place where people can play import UIKit // 初始化一个整数数组 var arr = [1, 3, 5, 7 ...