http://codeforces.com/contest/320/problem/B

这道题看了很长时间没看懂, 就是个dfs;

 #include <cstdio>
#include <cstring>
#define maxn 2000
using namespace std; int a[maxn],b[maxn];
bool vis[maxn];
int cnt=; bool dfs(int x,int y)
{
vis[x]=true;
if(x==y) return ;
for(int i=; i<=cnt; i++)
{
if(!vis[i]&&((a[i]<a[x]&&a[x]<b[i])||(a[i]<b[x]&&b[x]<b[i])))
{
if(dfs(i,y)) return true;
}
}
return false;
} int main()
{
int n,x,y,c;
scanf("%d",&n);
memset(vis,false,sizeof(vis));
for(int i=; i<=n; i++)
{
scanf("%d%d%d",&c,&x,&y);
if(c==)
{
a[cnt]=x; b[cnt++]=y;
}
else
{
memset(vis,false,sizeof(vis));
if(!dfs(x,y)) printf("NO\n");
else printf("YES\n");
}
}
return ;
}

cf Ping-Pong (Easy Version)的更多相关文章

  1. CF #579 (Div. 3) D1.Remove the Substring (easy version)

    D1.Remove the Substring (easy version) time limit per test2 seconds memory limit per test256 megabyt ...

  2. HDU 2492 Ping pong (树状数组)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2492 Ping pong Problem Description N(3<=N<=2000 ...

  3. UVALive 4329 Ping pong

                                      Ping pong Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Fo ...

  4. Ping-Pong (Easy Version)(DFS)

    B. Ping-Pong (Easy Version) time limit per test 2 seconds memory limit per test 256 megabytes input ...

  5. ZOJ 3868 - Earthstone: Easy Version

    3868 - Earthstone: Easy Version Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld ...

  6. POJ 3928 Ping pong(树状数组)

                                                                          Ping pong Time Limit: 1000MS   ...

  7. LA4329 Ping pong(树状数组与组合原理)

    N (3N20000)ping pong players live along a west-east street(consider the street as a line segment). E ...

  8. Ping pong

    Ping pong Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  9. POJ 3928 Ping pong

    题目链接:http://poj.org/problem?id=3928 乒乓比赛,有N个人参加,输入每个玩家的技能等级,对每个人设置一个特定ID和一个技能值,一场比赛需要两个选手和一个裁判,只有当裁判 ...

  10. Frequent values && Ping pong

    Frequent values 题意是不同颜色区间首尾相接,询问一个区间内同色区间的最长长度. 网上流行的做法,包括翻出来之前POJ的代码也是RMQ做法,对于序列上的每个数,记录该数向左和向右延续的最 ...

随机推荐

  1. ASP.NET获取IP的6种方法(转载于LanceZhang's Tech Blog)

    服务端: //方法一 HttpContext.Current.Request.UserHostAddress; //方法二 HttpContext.Current.Request.ServerVari ...

  2. HDU5140---Hun Gui Wei Company (主席树)

    主席树太强大了,,如果仅仅用来求第k大就太屈才了..貌似和HDU4605差不多,那个是在图上根据点的顺序建立主席树,这个是根据年龄大小 或者等级高低建立主席树. 题意 大致就是一个二维区间的求和,但是 ...

  3. [LeetCode] 203. Remove Linked List Elements 解题思路

    Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --& ...

  4. CF-Mr. Kitayuta's Colorful Graph

    B. Mr. Kitayuta's Colorful Graph time limit per test 1 second memory limit per test 256 megabytes in ...

  5. HDOJ 1248

    完全背包. 模版. 物品的价值等价于体积. #include <stdio.h> #include <string.h> using namespace std; int ma ...

  6. vb安装过程中 ntvdm.exe[9696]中发生未处理的win32异常

    最近电脑总是出问题导致我的学习效率很低,前几天在用VB6.0的时候有个知识点不太熟悉,于是按F1发现不会出来帮助文档.突然想到重新装系统之后忘记了安装MSDN帮助插件,就在我安装这个软件的时候发现电脑 ...

  7. zabbix流量汇聚

    "服务器流量汇总"领导提需求,要把几个数据中心的数据汇总起来,于是就google了一下"zabbix流量汇总" 按照其中一篇博客做了出来,博客地址如下. htt ...

  8. 移动端页面V2.0项目改版总结

    移动端页面已经进行的第三次改版,这个版本遇到的最大难题就是页面跳转的问题. 项目需求: 页面上有分别有优惠估价.我要估价.历史竞拍这三个Tab选项卡,当用户点击估价,选择品牌以后,前端需要去请求品牌接 ...

  9. script标签的位置

    1.在我们编写代码的时候,会在页面内使用<script>标签来写JS,虽然理论上script标签的位置放在哪里可以,但是还是有一点区别的. 2.为什么很多人把script标签放在底部: 初 ...

  10. 查看ip地址信息和配置临时ip

    查看ip地址信息:ifconfig –a 配置临时ip: ifconfig eth0 192.168.11.107