[杂题] Codeforces Gym 101190 NEERC 16 K. Kids Designing Kids

其实就是三个图异或起来为空
要的就是个观察

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<cstdio>
#include<cstdlib>
#include<algorithm>
#include<set>
#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<abcd> 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<abcd> &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<abcd> &A,abcd &Ad,set<abcd> &B,abcd &Bd,set<abcd> &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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值