$n \leq 100000,m \leq 100000$,给长度$n$的字符串$s$和$m$的字符串$t$,只含ABC。定义串$a$可以经过任意次如下操作变成其他串。

现在$q \leq 100000$个询问每次给俩串各指定一个子串,问串$s$的子串能否变成串$t$的子串。

这个题叫细节题,送tourist下榜的。。极其恐怖。更恐怖的是他看起来是模拟题,而且pretest极弱,鬼都不知道自己错哪,先给场上AC的各位大佬献个膝盖。

好开始。首先有重要性质:$B->AC->AAB->AAAC->C$,$C->AB->AAC->AAAB->B$,所以$B=C$,且$AB->B$,因此把$C$看成$B$。而又$B->AC$,$A->BC$,得$B->AB$,$A->BB$,因此$B$前的$A$可以自由增减,且$A$可炸成$BB$。因此把目光投到后缀中的$A$。

首先如果目标串$B$比原始串少,由于$B$无法凭空消失,因此死。

如果$t$中有后缀$A$,$s$是无法凭空制造后缀$A$的,因此必须保留至少同样的数量,否则死。

如果有多出来的$A$,可以炸成$B$,也可三个三个消掉。那就看情况,如果目标串中的$B$和原始串一样,那就不得不三个三个消掉;如果目标串$B$比原始串多,那原始串要么得至少有个$B$,要么得炸一个$A$,您可能想说,不是肯定至少有个$A$或$B$吗不然串就空了那问个毛线,告诉您,这里的$A$是指抵消掉后缀后的!!

 //#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
//#include<time.h>
//#include<complex>
#include<algorithm>
#include<stdlib.h>
using namespace std; int n,m,q;
#define maxn 200011
char s[maxn],t[maxn];
int ms[maxn],mt[maxn],sums[maxn],sumt[maxn];
int main()
{
scanf("%s%s",s+,t+);
n=strlen(s+); m=strlen(t+);
for (int i=;i<=n;i++) sums[i]=sums[i-]+(s[i]!='A'),ms[i]=s[i]=='A'?ms[i-]+:;
for (int i=;i<=m;i++) sumt[i]=sumt[i-]+(t[i]!='A'),mt[i]=t[i]=='A'?mt[i-]+:;
scanf("%d",&q);
while (q--)
{
int x1,y1,x2,y2; scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
int ss=sums[y1]-sums[x1-],tt=sumt[y2]-sumt[x2-];
if (((ss&)^(tt&)) || ss>tt) {putchar(''); continue;}
int aa=min(ms[y1],y1-x1+)-min(mt[y2],y2-x2+);
if (aa<) {putchar(''); continue;}
if (tt==ss)
{
if (aa%) putchar('');
else putchar('');
}
else
{
if (aa || ss) putchar('');
else putchar('');
}
}
return ;
}

Codeforces947D. Picking Strings的更多相关文章

  1. 【CodeForces】947 D. Picking Strings

    [题目]D. Picking Strings [题意]给定只含'A','B','C'的字符串,支持以下变换:1.A - BC   2.B - AC   3.C - AB   4.AAA - empty ...

  2. Codeforces 923 D. Picking Strings

    http://codeforces.com/contest/923/problem/D 题意: A-->BC , B-->AC , C-->AB , AAA-->empty 问 ...

  3. Codeforces Round #470 (rated, Div. 1, based on VK Cup 2018 Round 1) 923D 947D 948E D. Picking Strings

    题: OvO http://codeforces.com/contest/947/problem/D 923D 947D 948E 解: 记要改变的串为 P1 ,记目标串为 P2  由变化规则可得: ...

  4. 【codeforces】【比赛题解】#948 CF Round #470 (Div.2)

    [A]Protect Sheep 题意: 一个\(R*C\)的牧场中有一些羊和一些狼,如果狼在羊旁边就会把羊吃掉. 可以在空地上放狗,狼不能通过有狗的地方,狼的行走是四联通的. 问是否能够保护所有的羊 ...

  5. VK Cup 2018 - Round 1+Codeforces Round #470

    A. Primal Sport 题意:有两个人轮流玩游戏.给出数X(i-1),轮到的人需要找到一个小于X(i-1)的素数x,然后得到Xi,Xi是x的倍数中大于等于X(i-1)的最小的数.现在已知X2, ...

  6. Codeforces Round #470 Div. 2题解

    A. Protect Sheep time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  7. Hacker Rank: Two Strings - thinking in C# 15+ ways

    March 18, 2016 Problem statement: https://www.hackerrank.com/challenges/two-strings/submissions/code ...

  8. StackOverFlow排错翻译 - Python字符串替换: How do I replace everything between two strings without replacing the strings?

    StackOverFlow排错翻译 - Python字符串替换: How do I replace everything between two strings without replacing t ...

  9. Multiply Strings

    Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...

随机推荐

  1. 线程池ThreadPoolExecutor参数分析

    概述 比如去火车站买票, 有7个(maximumPoolSize)售票窗口, 但只有3个(corePoolSize)窗口对外开放.那么对外开放的3个窗口称为核心线程数, 而最大线程数是7个窗口. 如果 ...

  2. QWidget标题栏双击事件

    widget.h virtual bool event(QEvent *event); widget.cpp bool Widget::event(QEvent *event) { if (event ...

  3. git设置log的别名 for hist

    hist -- alias for 'log --color --graph --date=short --pretty=format:'%Cred%h%Creset -%C(yellow)%d%C ...

  4. C# 移动开发(Xamarin.Form) Plugin.BLE 蓝牙连接

    随着Xamarin.Form项目接近尾声,仔细一算才发现过来大半年时间了. 期间除了刚开始有闲情写写,现在总算有空来总结一下了. 来先说 Plugin.BLE (https://github.com/ ...

  5. Jmeter官网文档翻译

    Jmeter目录 入门 1.0概述 测试计划建设 负载测试运行 负载测试分析 开始吧 1.1要求 1.1.1 Java版本 1.1.2操作系统 1.2可选 1.2.1 Java编译器 1.2.2 SA ...

  6. VBA Promming——入门教程

    VBA Visual Basic for Applications(VBA)是Visual Basic的一种宏语言,是微软开发出来在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言.主要能用来 ...

  7. Graveyard LA3708

    白书第一章例题4 思维. 先固定一点不动,假设最后一共N个点,那么编号为0,1,...N-1, 0不动,原来的n个点分别占据i/n*N的位置(记为pos),移动到pos四舍五入的位置即可. 证明一:有 ...

  8. 一条HTTP的生命之旅(高频面试问题)

    当你在浏览器地址栏输入一个URL后回车,将会发生的事情? 原文:http://igoro.com/archive/what-really-happens-when-you-navigate-to-a- ...

  9. Perl: hash散列转换为Json报错集, perl.c,v $$Revision: 4.0.1.8 $$Date: 1993/02/05 19:39:30 $

    bash-2.03$ ./u_json.pl Can't locate object method "encode" via package "JSON" at ...

  10. windows10下Anaconda的安装与tensorflow、opencv的安装与环境配置

    刚开始学习tensorflow和opencv这一块的知识,所以用博客这个平台来把自己这段学习的经历与感想写下来. tensorflow和opencv则用Anaconda来下载和配置环境. 下载Anac ...