题目链接:

https://jzoj.net/senior/#main/show/5177

题目:

题解:

首先选出的泡泡怪一定是连续的一段 L,R

然后 L 一定属于虫洞左边界中的某一个 R 也同样是这样的

这样就可以枚举 L 和 R,$O(N)$判断是否可行(显然不可能重复经过某个点),总复杂度 $O(NM^2)$

我们看到 R<=1e6 选择二分 R 而不是枚举,这样就可以了

#include<algorithm>
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std; const int N=1e3+;
const int M=3e3+;
const int inf=1e6;
int n,m,tot;
int head[N],L[M],vis[N];
struct EDGE{
int to,nxt,l,r;
}edge[M<<];
inline int read(){
char ch=getchar();int s=,f=;
while (ch<''||ch>'') {if (ch=='-') f=-;ch=getchar();}
while (ch>=''&&ch<='') {s=(s<<)+(s<<)+ch-'';ch=getchar();}
return s*f;
}
void link(int u,int v,int l,int r){
edge[++tot]=(EDGE){v,head[u],l,r};
head[u]=tot;
}
bool dfs(int x,int l,int r)
{
if (x==n) return ;
if (vis[x]) return ;
vis[x]=;
for (int i=head[x];i;i=edge[i].nxt)
{
if (edge[i].l<=l&&edge[i].r>=r)
{
if (dfs(edge[i].to,l,r)) return ;
}
}
return ;
}
bool check(int l,int r)
{
memset(vis,,sizeof(vis));
if (dfs(,l,r)) return ;
return ;
}
int main()
{
n=read();m=read();
for (int i=,u,v,l,r;i<=m;i++){
u=read();v=read();l=read();r=read();
link(u,v,l,r);link(v,u,l,r);
L[i]=l;
}
sort(L+,L++m);
int ans=,al,ar;
for (int i=m;i;i--){
int l=L[i],r=inf;
while (l+<r)
{
int mid=l+r>>;
if (check(L[i],mid))
{
if (mid-L[i]+>=ans)
{
ans=mid-L[i]+;
al=L[i];ar=mid;
}
l=mid;
}
else r=mid;
}
}
printf("%d\n",ans);
for (int i=al;i<=ar;i++) printf("%d ",i);
return ;
}

[jzoj 5177] [NOIP2017提高组模拟6.28] TRAVEL 解题报告 (二分)的更多相关文章

  1. [jzoj 5178] [NOIP2017提高组模拟6.28] So many prefix? 解题报告(KMP+DP)

    题目链接: https://jzoj.net/senior/#main/show/5178 题目: 题解: 我们定义$f[pos]$表示以位置pos为后缀的字符串对答案的贡献,答案就是$\sum_{i ...

  2. [JZOJ 5852] [NOIP2018提高组模拟9.6] 相交 解题报告 (倍增+LCA)

    题目链接: http://172.16.0.132/senior/#main/show/5852 题目: 题目大意: 多组询问,每次询问树上两条链是否相交 题解: 两条链相交并且仅当某一条链的两个端点 ...

  3. [JZOJ5178]【NOIP2017提高组模拟6.28】So many prefix?

    Description

  4. nowcoder(牛客网)提高组模拟赛第一场 解题报告

    T1 中位数(二分) 这个题是一个二分(听说是上周atcoder beginner contest的D题???) 我们可以开一个数组b存a,sort然后二分b进行check(从后往前直接遍历check ...

  5. JZOJ 5184. 【NOIP2017提高组模拟6.29】Gift

    5184. [NOIP2017提高组模拟6.29]Gift (Standard IO) Time Limits: 1000 ms  Memory Limits: 262144 KB  Detailed ...

  6. JZOJ 5196. 【NOIP2017提高组模拟7.3】B

    5196. [NOIP2017提高组模拟7.3]B Time Limits: 1000 ms  Memory Limits: 262144 KB  Detailed Limits   Goto Pro ...

  7. JZOJ 5197. 【NOIP2017提高组模拟7.3】C

    5197. [NOIP2017提高组模拟7.3]C Time Limits: 1000 ms  Memory Limits: 262144 KB  Detailed Limits   Goto Pro ...

  8. JZOJ 5195. 【NOIP2017提高组模拟7.3】A

    5195. [NOIP2017提高组模拟7.3]A Time Limits: 1000 ms  Memory Limits: 262144 KB  Detailed Limits   Goto Pro ...

  9. JZOJ 5185. 【NOIP2017提高组模拟6.30】tty's sequence

    5185. [NOIP2017提高组模拟6.30]tty's sequence (Standard IO) Time Limits: 1000 ms  Memory Limits: 262144 KB ...

随机推荐

  1. eclips 手机 offline

    [退出eclipse] [进入eclipse的工作区间] [删除 .metadata文件夹,确保 .metadata文件夹得隐藏文件也要删除] [重启eclipse,并重新导入你的工程]

  2. kentico在使用局域网ip访问的时候提示Missing license或者Invalid website

    Missing license Requested URL: http://172.31.212.20/kentico10/ License status: Missing license If yo ...

  3. 杂项-DB-分布式:HBase

    ylbtech-杂项-DB-分布式:HBase HBase是一个分布式的.面向列的开源数据库,该技术来源于 Fay Chang 所撰写的Google论文“Bigtable:一个结构化数据的分布式存储系 ...

  4. [jzoj 6093] [GDOI2019模拟2019.3.30] 星辰大海 解题报告 (半平面交)

    题目链接: https://jzoj.net/senior/#contest/show/2686/2 题目: 题解: 说实话这题调试差不多花了我十小时,不过总算借着这道题大概了解了计算几何的基础知识 ...

  5. 子线程中刷新了UI

    This application is modifying the autolayout engine from a background thread, which can lead to engi ...

  6. JQuery (总结)

    延迟触发事件 Ajax异步请求数据 Jquery事件: Focus获得焦点 blur失去焦点 Change内容在变化的时候 Click点击事件 ---------------------------- ...

  7. jQuery应用实例3:鼠标经过显示离开隐藏

    效果: 代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...

  8. datatable.rows.indexof(dr)返回的是啥?

    返回的是Int类型的 行索引值,从0开始.也就是说,第一行是0.最后一行就是rows.count - 1.不会返回-1."这是第" + OldDt.Rows.IndexOf(ite ...

  9. UVa 11549 Open Credit System

    题意:给出n个数,找出两个整数a[i],a[j](i < j),使得a[i] - a[j]尽量大 从小到大枚举j,在这个过程中维护a[i]的最大值 maxai晚于ans更新, 可以看这个例子 1 ...

  10. [HDU1160]FatMouse's Speed

    题目大意:读入一些数(每行读入$w[i],s[i]$为一组数),要求找到一个最长的序列,使得符合$w[m[1]] < w[m[2]] < ... < w[m[n]]$且$s[m[1] ...