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& ...
随机推荐
- Spring-----1、Spring一个简短的引论
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaGVrZXdhbmd6aQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...
- ios开发应用内实现多语言自由切换
需求描述:应用内部有一按钮,点击切换语言(如中英文切换).说起来这个是好久以前做的一个功能点了,刚开始也是没有头绪,后来解决了发现很简单,把方法分享一下.1.原理.查看NSLocalizedStrin ...
- [转] Makefile中调用Shell
1.在Makefile中只能在target中调用Shell脚本,其他地方是不能输出的.比如如下代码就是没有任何输出: VAR="Hello" echo "$(VAR)&q ...
- HttpWebRequest get/post方法实现
get请求url #region GetHttp请求 /// <summary> /// GetHttp请求 /// </summary> /// <param name ...
- JavaScript 总结
1. JavaScript prototype属性是一个对象 当一个函数在定义之后 就会自动获得这个属性.其初始值是一个空对象.新建了一个名为Cat的构造函数,其prototype为一个对象,cons ...
- Linux 机器之间建立互信
原理: 就是两台机器(web-1和web-2)经过预先设置好经过认证的key文件,双方互相访问时,进行自动认证,从而实现互信. 互信的原理了解了,我们可以把配置ssh互信的步骤进行有效的分割. 1 ...
- Matcher Pattern 正则表达式 示例
示例 public class Test { public static void main(String[] args) throws IOException { Patte ...
- 武汉科技大学ACM:1004: 华科版C语言程序设计教程(第二版)习题5.6
Problem Description 这天老师又给小豪出了一道题目:给你三根长度分别为a,b,c的火柴,让你计算这三跟火柴能组成的三角形的面积. Input 输入每行包括三个数a,b,c. Outp ...
- JavaScript Nested Function 的时空和身份属性
JavaScript 的function 不仅仅是一等公民,简直就是特殊公民.它有许多独特的特征: 1) 它是object,可以存储,传递,附加属性. 2) 它可以有lexical closure, ...
- 跟我学android-搭建Android开发环境(一)
Android官网地址:http://developer.android.com/,下载和安装 AndroidSDK请按如下步骤进行: 下载ADT 和SDK:http://developer.andr ...