其实就是三个图异或起来为空
要的就是个观察
after moving the figures, some two of these three freckles must be in the same point.
There are only three possible shifts, check them all
#include
#include
#include
#include
#define X first
#define Y second
using namespace std;
typedef pair<int,int> abcd;
inline char nc(){
static char buf[100000],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline void read(int &x){
char c=nc(),b=1;
for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
inline void read(char *s){
char c=nc(); int len=0;
for (;!(c=='.' || c=='*');c=nc());
for (;c=='.' || c=='*';s[++len]=c,c=nc());
}
abcd Ad,Bd,Cd;
set A,B,C,T,S;
abcd operator + (const abcd &A,const abcd &B){
return abcd(A.X+B.X,A.Y+B.Y);
}
inline void Read(set &A,abcd &Ad){
static int n,m; static char s[1005];
read(n); read(m);
int f=0;
for (int i=1;i<=n;i++){
read(s);
for (int j=1;j<=m;j++)
if (s[j]=='*'){
if (!f) Ad=abcd(-i,-j),f=1;
A.insert(abcd(i,j)+Ad);
}
}
}
inline bool Pd(set &A,abcd &Ad,set &B,abcd &Bd,set &C,abcd &Cd){
T.clear();
for (abcd i:A)
T.insert(i);
for (abcd i:B)
if (T.count(i))
T.erase(i);
else
T.insert(i);
abcd t=*T.begin();
if (C.size()!=T.size()) return 0;
for (abcd i:C)
if (!T.count(i+t))
return 0;
Cd=Cd+t;
return 1;
}
int main(){
freopen("kids.in","r",stdin);
freopen("kids.out","w",stdout);
Read(A,Ad); Read(B,Bd); Read(C,Cd);
if (Pd(A,Ad,B,Bd,C,Cd) || Pd(A,Ad,C,Cd,B,Bd) || Pd(B,Bd,C,Cd,A,Ad))
printf("YES\n%d %d",Bd.Y-Ad.Y,Bd.X-Ad.X);
else
printf("NO\n");
return 0;
}