当前位置:网站首页>[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 */
边栏推荐
- Map and set
- 深拷貝 事件總線
- PR 2021 quick start tutorial, learn about the and functions of the timeline panel
- arcgis js 4. Add pictures to x map
- kubenetes中port、targetPort、nodePort、containerPort的区别与联系
- Leetcode122 the best time to buy and sell stocks II
- 浏览器存储方案
- Brush questions --- binary tree --2
- Drools dynamically add, modify, and delete rules
- BOM DOM
猜你喜欢

CDA数据分析——AARRR增长模型的介绍、使用

drools决策表的简单使用

Docker compose configuration mysql, redis, mongodb

Simple understanding of ThreadLocal

Simple use of drools decision table

arcgis js 4.x 地图中加入图片

Record the range of data that MySQL update will lock

刷题---二叉树--2
![[old horse of industrial control] detailed explanation of Siemens PLC TCP protocol](/img/13/9002244555ebe8a61660c2506993fa.png)
[old horse of industrial control] detailed explanation of Siemens PLC TCP protocol

Take you ten days to easily finish the finale of go micro services (distributed transactions)
随机推荐
CPU指令集介绍
Go学习笔记—多线程
Simple understanding of ThreadLocal
SSH automatically disconnects (pretends to be dead) after a period of no operation
Fresh, 2022 advanced Android interview must know 100 questions (interview questions + answer analysis)
Fastdateformat why thread safe
Natural language processing series (I) -- RNN Foundation
WSL 2 will not be installed yet? It's enough to read this article
Leetcode209 长度最小的子数组
Sse/avx instruction set and API of SIMD
(C language) input a line of characters and count the number of English letters, spaces, numbers and other characters.
Lekao.com: experience sharing of junior economists and previous candidates in customs clearance
Openssh remote enumeration username vulnerability (cve-2018-15473)
Find the common ancestor of any two numbers in a binary tree
ThreadLocal的简单理解
Leetcode14 longest public prefix
drools执行指定的规则
Go learning notes - go based interprocess communication
drools决策表的简单使用
MySQL indexes and transactions