当前位置: 首页 > news >正文

织梦网站做图床/四川seo整站优化吧

织梦网站做图床,四川seo整站优化吧,学校网站建设实训总结,河北响应式网站建设平台D. Guess Your Way Out! II Problems Link: http://codeforces.com/problemset/problem/558/D Mean: 一棵满二叉树,树中某个叶子节点是出口,目的是寻找这个出口。再给定Q个询问的结果,每个结果告诉我们在第i层中(l,r)覆盖的叶结点是否包含出…

 D. Guess Your Way Out! II

Problem's Link: http://codeforces.com/problemset/problem/558/D


 

Mean: 

一棵满二叉树,树中某个叶子节点是出口,目的是寻找这个出口。再给定Q个询问的结果,每个结果告诉我们在第i层中(l,r)覆盖的叶结点是否包含出口。

analyse:

基本思路:多个区间求交集。

具体实现:

对于每一个询问,把它转化到最底层。并且把不在(l,r)区间的询问改为在(最左边,l-1)和(r+1,最右边)的形式,这样一来全部都变成了在(l,r)区间的描述。

区间统计:

对左右区间起点和终点组成的集合进行排序。然后找到答案存在的区间,如果区间长度=1,答案唯一;长度>1,答案不唯一;长度=0,无解。

Trick:会爆int。

Time complexity: O(n)

 

Source code: 

/*
* this code is made by crazyacking
* Verdict: Accepted
* Submission Date: 2015-07-16-11.55
* Time: 0MS
* Memory: 137KB
*/
#include <queue>
#include <cstdio>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#include <climits>
#include <map>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#define  LL long long
#define  ULL unsigned long long
using namespace std;
LL L[51], R[51];
int main()
{ios_base::sync_with_stdio( false );cin.tie( 0 );L[1] = 1, R[1] = 1;for( int i = 2; i <= 50; ++i ) L[i] = L[i - 1] << 1, R[i] = ( L[i] << 1 ) - 1;int h, q;cin >> h >> q;if( q == 0 ){if( h == 1 ) puts( "1" );else puts( "Data not sufficient!" );return 0;}map<LL, int> mp;for( int i = 0; i < q; ++i ){LL level, left, right, type, gap;cin >> level >> left >> right >> type;gap = h - level;while( gap ){gap--;left <<= 1;right = ( ( right + 1 ) << 1 ) - 1;}if( type ){mp[left]++;mp[right + 1]--;}else{mp[L[h]]++;mp[left]--;mp[right + 1]++;mp[R[h] + 1]--;}}LL ans, sum = 0, ans_gap = 0, mid_pre = -1;map<LL, int>:: iterator it = mp.begin();for( ; it != mp.end(); ++it ){sum += ( it->second );if( mid_pre != -1 ){ans_gap += ( it->first ) - mid_pre;ans = mid_pre;}if( sum == q ) mid_pre = ( it->first );else mid_pre = -1;}if( ans_gap == 1 ) cout << ans << endl;else if( ans_gap > 1 ) puts( "Data not sufficient!\n" );else puts( "Game cheated!\n" );return 0;
}
/**/

 

转载于:https://www.cnblogs.com/crazyacking/p/4652310.html

http://www.jmfq.cn/news/5236759.html

相关文章:

  • 在线播放视频网站怎么做/西安百度竞价托管公司
  • dede网站底部/百度seo排名推广
  • 科普重庆网站/天津seo网站管理
  • 如何用虚拟主机做网站/seo排名点击器
  • 制作免费个人网站/sem是什么设备
  • 目前b2b网站有哪些/atp最新排名
  • 怎么做粉丝福利购网站/seo公司上海
  • 设计师分享网站/上海做网站优化
  • 云存储能用来做网站吗/网站推广方案有哪些
  • 鞍山 中企动力提供网站建设/深圳网络推广大师
  • 无忧网站建设服务/邯郸今日头条最新消息
  • wordpress 首页欢迎/seo综合优化公司
  • 学校定制网站建设公司/网站关键词排名seo
  • 专做零食的网站/杭州百度快照优化排名
  • 网站开发有哪些语言/seo综合查询什么意思
  • 给别人做的网站涉及到诈骗/怎样申请网站
  • wordpress网站的CDN设置/齐三seo顾问
  • 建设网站计划书/百度推广登录平台
  • 学校网站建设的技术方案/北京seo包年
  • 西宁公司官方网站建设/搜狗搜索网页版
  • 免费制作网络商城网站/百度空间登录入口
  • 网页设计制作图片代码/免费seo快速排名系统
  • 怎么用别人网站做模板/百度经验首页登录官网
  • 怎么介绍自己做的静态网站/深圳seo优化外包公司
  • 吉安做网站的公司/短视频推广策略
  • 南宁营销型网站建设公司哪家好/最新足球消息
  • 长沙网站建设zh68/优化师培训机构
  • 淘宝网站用什么语言做的/武汉大学人民医院洪山院区
  • 免费的网站推广怎么做效果好/寰宇seo
  • 网上商城可行性分析报告/四川最好的网络优化公司