分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

http://codeforces.com/gym/100623/attachments E题

发布时间:2023-09-21 20:32责任编辑:彭小芳关键词:http

http://codeforces.com/gym/100623/attachments E题
第一个优化
它虽然是镜像对称,但它毕竟是一一对称的,所以可以匹配串和模式串都从头到尾颠倒一下
第二个优化,与次数无关,所以排个序就完事了

 1 #include<iostream> 2 #include<cstdio> 3 #include<queue> 4 #include<algorithm> 5 #include<cmath> 6 #include<ctime> 7 #include<set> 8 #include<map> 9 #include<stack>10 #include<cstring>11 #define inf 214748364712 #define ls rt<<113 #define rs rt<<1|114 #define lson ls,nl,mid,l,r15 #define rson rs,mid+1,nr,l,r16 #define N 10001017 #define For(i,a,b) for(int i=a;i<=b;i++)18 #define p(a) putchar(a)19 #define g() getchar()20 21 using namespace std;22 int n;23 char a[110],b[110],c[110],d[110];24 25 struct node{26 ????int f;27 ????int s;28 ????bool operator < (const node & temp)const{29 ????????if(f==temp.f)30 ????????????return s<temp.s;31 ????????return f<temp.f;32 ????}33 }a1[110],a2[110];34 35 void in(int &x){36 ????int y=1;37 ????char c=g();x=0;38 ????while(c<‘0‘||c>‘9‘){39 ????????if(c==‘-‘)y=-1;40 ????????c=g();41 ????}42 ????while(c<=‘9‘&&c>=‘0‘){43 ????????x=(x<<1)+(x<<3)+c-‘0‘;c=g();44 ????}45 ????x*=y;46 }47 void o(int x){48 ????if(x<0){49 ????????p(‘-‘);50 ????????x=-x;51 ????}52 ????if(x>9)o(x/10);53 ????p(x%10+‘0‘);54 }55 int main(){56 ????freopen("enchanted.in","r",stdin);57 ????freopen("enchanted.out","w",stdout);58 ????cin>>(a+1)>>(b+1)>>(c+1)>>(d+1);59 ????n=strlen(a+1);60 ????For(i,1,n){61 ????????a1[i].f=a[i]-‘A‘+1;62 ????????a1[i].s=b[n-i+1]-‘A‘+1;63 ????}64 ????For(i,1,n){65 ????????a2[i].f=c[i]-‘A‘+1;66 ????????a2[i].s=d[n-i+1]-‘A‘+1;67 ????}68 ????sort(a1+1,a1+n+1);69 ????sort(a2+1,a2+n+1);70 ????For(i,1,n)71 ????????if(a1[i].f!=a2[i].f||a1[i].s!=a2[i].s){72 ????????????cout<<"No";73 ????????????return 0;74 ????????}75 ????cout<<"Yes";76 ????return 0;77 }
View Code

http://codeforces.com/gym/100623/attachments E题

原文地址:https://www.cnblogs.com/war1111/p/10798110.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved