大意: 给定序列$a$, $a_i$为偶数代表第$\frac{a_i}{2}$种左括号, 否则为第$\frac{a_i-1}{2}$种右括号. 询问区间是否是合法括号序列.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#include <unordered_map>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, P2 = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
template <class T> void rd(T &x){x=0;bool f=0;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=1;c=getchar();}while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}if(f)x=-x;}
//head const int N = 4e6+10;
int n,m,q,a[N],s[N],L[N]; int main() {
scanf("%d%d%d", &n, &m,&q);
REP(i,1,n) scanf("%d",a+i);
int top = 0;
REP(i,1,n) {
if (!top) s[++top] = i;
else {
if (a[i]/2==a[s[top]]/2&&a[i]==a[s[top]]+1) --top;
else s[++top] = i;
}
L[i] = s[top];
}
REP(i,1,q) {
int x, y;
scanf("%d%d", &x, &y);
puts(L[x-1]==L[y]?"Yes":"No");
}
}

最新文章

  1. 微信JSAPI支付
  2. 浅谈MySql的存储引擎(表类型)
  3. 减少C++代码编译时间的方法
  4. phalcon(费尔康)框架学习笔记
  5. c++ 完成端口资料
  6. JavaScript:子ウィンドウから親ウィンドウを再読み込みさせる方法
  7. js 实现关键词球状旋转效果
  8. css经典布局—stick footer布局
  9. 随机获取min和max之间的一个整数
  10. 论文笔记:Prediction-Tracking-Segmentation
  11. CUDA compiler driver nvcc 散点 part 2
  12. 大数据学习笔记3 - 并行编程模型MapReduce
  13. bzoj1912 树形dp求直径(新写法),求直径的两端点
  14. Java中sort实现降序排序
  15. shell 脚本学习之read
  16. 学习mysql replication gitd
  17. ubuntu13.04 搭建 Nginx + PHP + PHP-FPM + Mysql (lnmp) 环境
  18. CentOS7 msmtp+mutt发送邮件
  19. 添加APP右上角数字提醒标识
  20. 并发之CAS无锁技术

热门文章

  1. Kafka - SASL认证
  2. pwn学习日记Day21 《程序员的自我修养》读书笔记
  3. VMware下的CentOS7在桥接模式下,设置静态ip联网
  4. 粘性定位 sticky
  5. Python 自学笔记(一)
  6. LINUX 上 实现SNTP (时间同步)
  7. 免费版CloudFlare CDN基本设置参考
  8. SQL-W3School-高级:SQL 撤销索引、表以及数据库
  9. 广告行业——数字广告营销中的DSP、SSP、RTB是个什么概念
  10. HBase管理与监控——Dead Region Servers