当前位置:网站首页>[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 */
边栏推荐
- OpenCV中cv2.VideoWriter_fourcc()函数和cv2.VideoWriter()函数的结合使用
- 中国交通标志检测数据集
- MySQL与PostgreSQL抓取慢sql的方法
- Differences between nodes and sharding in ES cluster
- mysql索引和事务
- Leetcode - Sword finger offer 59 - I, 59 - II
- Drools terminates the execution of other rules after executing one rule
- Intel internal instructions - AVX and avx2 learning notes
- Lekao.com: experience sharing of junior economists and previous candidates in customs clearance
- PR 2021 quick start tutorial, learn about the and functions of the timeline panel
猜你喜欢
The programmer and the female nurse went on a blind date and spent 360. He packed leftovers and was stunned when he received wechat at night
Is the neural network (pinn) with embedded physical knowledge a pit?
堆(優先級隊列)
PR 2021 quick start tutorial, learn about the and functions of the timeline panel
刷题---二叉树--2
Fresh, 2022 advanced Android interview must know 100 questions (interview questions + answer analysis)
Brush questions --- binary tree --2
Openssh remote enumeration username vulnerability (cve-2018-15473)
Interview with meituan, a 34 year old programmer, was rejected: only those under the age of 30 who work hard and earn little overtime
China traffic sign detection data set
随机推荐
Find the factorial of a positive integer within 16, that is, the class of n (0= < n < =16). Enter 1111 to exit.
Leetcode209 长度最小的子数组
AI中台技术调研
AAAI 2022 | Peking University & Ali Dharma Institute: pruning and compression of pre training language model based on comparative learning
Embedded Software Engineer career planning
使用Sqoop把ADS层数据导出到MySQL
ThreadLocal的简单理解
Writing method of then part in drools
[I'm a mound pytorch tutorial] learning notes
初始JDBC 编程
Go learning notes - go based interprocess communication
LeetCode—剑指 Offer 59 - I、59 - II
Day12 control flow if switch while do While guessing numbers game
drools执行String规则或执行某个规则文件
Error in kubeadm join: [error port-10250]: port 10250 is in use [error fileavailable--etc kubernetes PKI
全链路压测
Adding database driver to sqoop of cdh6
浏览器存储方案
Differences between nodes and sharding in ES cluster
二分刷题记录(洛谷题单)区间的甄别