当前位置:网站首页>[ybtoj advanced training guide] similar string [string] [simulation]
[ybtoj advanced training guide] similar string [string] [simulation]
2022-07-02 12:33:00 【VL—MOESR】

Ideas :
Because similarity is transitive , You can directly recursively judge
c o d e code code
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int t;
bool campare_(char *s1, char *s2, int len)
{
for(int i=0; i<len; i++)
if(s1[i]>s2[i])
return 1;
else if(s1[i]<s2[i])
return 0;
return 0;
}
bool check(char *s1, char *s2, int len)
{
// cout<<s1<<' '<<s2<<endl;
for(int j=0; j<len; j++)
if(s1[j]!=s2[j])
{
if(len&1)
return 0;
int slen=len/2;
char a[slen+10], b[slen+10], c[slen+10], d[slen+10];
for(int i=0; i<slen; i++)
a[i]=s1[i], c[i]=s2[i];
for(int i=slen; i<len; i++)
b[i-slen]=s1[i], d[i-slen]=s2[i];
if(campare_(a, b, slen))
for(int i=0; i<slen; i++)
swap(a[i], b[i]);
if(campare_(c, d, slen))
for(int i=0; i<slen; i++)
swap(c[i], d[i]);
return (check(a, c, slen)&&check(b, d, slen))||(check(a, d, slen)&&(check(b, c, slen)));
}
return 1;
}
int main()
{
scanf("%d ", &t);
while(t--)
{
char s[500010], ss[500010];
scanf("%s", s);
scanf("%s", ss);
if(check(s, ss, strlen(s)))
printf("YES\n");
else printf("NO\n");
}
return 0;
}
/* ccfnzfnw wnfzccnf */
边栏推荐
- 二分刷题记录(洛谷题单)区间的甄别
- Drools terminates the execution of other rules after executing one rule
- drools动态增加、修改、删除规则
- The most understandable f-string tutorial in history, collecting this one is enough
- arcgis js 4.x 地图中加入图片
- Heap (priority queue)
- This "little routine" is set on the dough cake of instant noodles. No wonder programmers are always hungry
- drools决策表的简单使用
- Interview with meituan, a 34 year old programmer, was rejected: only those under the age of 30 who work hard and earn little overtime
- CV2 in OpenCV VideoWriter_ Fourcc() function and cv2 Combined use of videowriter() function
猜你喜欢

Map and set

Use sqoop to export ads layer data to MySQL

There is a hidden danger in CDH: the exchange memory used by the process of this role is XX megabytes. Warning threshold: 200 bytes

CDH6之Sqoop添加数据库驱动

Experiment of connecting mobile phone hotspot based on Arduino and esp8266 (successful)

Embedded Software Engineer career planning

倍增 LCA(最近公共祖先)

"As a junior college student, I found out how difficult it is to counter attack after graduation."

ThreadLocal的简单理解

Brush questions --- binary tree --2
随机推荐
二分刷题记录(洛谷题单)区间的甄别
CPU指令集介绍
刷题---二叉树--2
mysql索引和事务
Sparkcontext: error initializing sparkcontext solution
Input a three digit number and output its single digit, ten digit and hundred digit.
PyTorch nn. Full analysis of RNN parameters
Experiment of connecting mobile phone hotspot based on Arduino and esp8266 (successful)
The blink code based on Arduino and esp8266 runs successfully (including error analysis)
Test shift left and right
[old horse of industrial control] detailed explanation of Siemens PLC TCP protocol
arcgis js 4. Add pictures to x map
drools决策表的简单使用
WSL 2 will not be installed yet? It's enough to read this article
5g era, learning audio and video development, a super hot audio and video advanced development and learning classic
Go learning notes - multithreading
lombok常用注解
Interview with meituan, a 34 year old programmer, was rejected: only those under the age of 30 who work hard and earn little overtime
AI mid stage technology research
PR 2021 quick start tutorial, learn about the and functions of the timeline panel