标签:struct std bzoj etc poi2015 freopen 覆盖 pre out
1 #include <bits/stdc++.h> 2 #define il inline 3 #define RG register 4 #define ll long long 5 6 using namespace std; 7 8 struct data{ int x,y; }st[1000010]; 9 10 int vis[1010][1010],g[1010][1010],n,m,a,b,top; 11 12 il int gi(){ 13 RG int x=0,q=1; RG char ch=getchar(); 14 while ((ch<‘0‘ || ch>‘9‘) && ch!=‘-‘) ch=getchar(); 15 if (ch==‘-‘) q=-1,ch=getchar(); 16 while (ch>=‘0‘ && ch<=‘9‘) x=x*10+ch-48,ch=getchar(); 17 return q*x; 18 } 19 20 il char gc(){ 21 RG char ch=getchar(); 22 while (ch!=‘.‘ && ch!=‘x‘) ch=getchar(); return ch; 23 } 24 25 il void work(){ 26 n=gi(),m=gi(),a=gi(),b=gi(),top=0; 27 for (RG int i=1;i<=n;++i) 28 for (RG int j=1;j<=m;++j) g[i][j]=gc()==‘x‘,vis[i][j]=0; 29 for (RG int i=1;i<=a;++i) 30 for (RG int j=1;j<=b;++j) if (gc()==‘x‘) st[++top]=(data){i,j}; 31 for (RG int i=top;i;--i) st[i].x-=st[1].x,st[i].y-=st[1].y; 32 for (RG int i=1;i<=n;++i) 33 for (RG int j=1;j<=m;++j){ 34 if (!g[i][j] || vis[i][j]) continue; 35 for (RG int k=1,X,Y;k<=top;++k){ 36 X=i+st[k].x,Y=j+st[k].y; 37 if (X<=0 || X>n || Y<=0 || Y>m || vis[X][Y] || !g[X][Y]){ puts("NIE"); return; } 38 vis[X][Y]=1; 39 } 40 } 41 puts("TAK"); return; 42 } 43 44 int main(){ 45 #ifndef ONLINE_JUDGE 46 freopen("pieczec.in","r",stdin); 47 freopen("pieczec.out","w",stdout); 48 #endif 49 RG int T=gi(); 50 while (T--) work(); 51 return 0; 52 }
标签:struct std bzoj etc poi2015 freopen 覆盖 pre out
原文地址:http://www.cnblogs.com/wfj2048/p/7649873.html