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

 #include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<cstring>
#define inf 2147483647
#define ls rt<<1
#define rs rt<<1|1
#define lson ls,nl,mid,l,r
#define rson rs,mid+1,nr,l,r
#define N 100010
#define For(i,a,b) for(int i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar() using namespace std;
int n;
char a[],b[],c[],d[]; struct node{
int f;
int s;
bool operator < (const node & temp)const{
if(f==temp.f)
return s<temp.s;
return f<temp.f;
}
}a1[],a2[]; void in(int &x){
int y=;
char c=g();x=;
while(c<''||c>''){
if(c=='-')y=-;
c=g();
}
while(c<=''&&c>=''){
x=(x<<)+(x<<)+c-'';c=g();
}
x*=y;
}
void o(int x){
if(x<){
p('-');
x=-x;
}
if(x>)o(x/);
p(x%+'');
}
int main(){
freopen("enchanted.in","r",stdin);
freopen("enchanted.out","w",stdout);
cin>>(a+)>>(b+)>>(c+)>>(d+);
n=strlen(a+);
For(i,,n){
a1[i].f=a[i]-'A'+;
a1[i].s=b[n-i+]-'A'+;
}
For(i,,n){
a2[i].f=c[i]-'A'+;
a2[i].s=d[n-i+]-'A'+;
}
sort(a1+,a1+n+);
sort(a2+,a2+n+);
For(i,,n)
if(a1[i].f!=a2[i].f||a1[i].s!=a2[i].s){
cout<<"No";
return ;
}
cout<<"Yes";
return ;
}
05-11 15:41