改一下
查看原帖
改一下
1040714
DevinAlvin楼主2024/12/18 16:54

求大佬改一下 七分

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n--){
		int x,y;
		cin>>x;
		bool s=false;
		char a[x][x];
		for(int i=0;i<x;i++){
			for(int j=0;j<x;j++){
				cin>>a[i][j];
			}
		} 
		cin>>y;
		char b[4][y][y];
		for(int i=0;i<y;i++){
			for(int j=0;j<y;j++){
				cin>>b[0][i][j];
			}
		}
		if(y>x){
			cout<<"NO"<<endl;
			continue;
		}
		for(int j=1;j<4;j++){
			for(int i=0;i<y;i++){
				for(int h=y-1;h>=0;h--){
					b[j][i][h]=b[j-1][y-1-h][i];
				}
			}
		}
		
		for(int i=0;i<=x-y;i++){
            if(s)break;
			for(int j=0;j<=x-y;j++){
                if(s)break;
				for(int k=0;k<4;k++){
					int ans=0;
					for(int l=0;l<y;l++){
						for(int h=0;h<y;h++){
							if(b[k][l][h]==a[i+l][j+h]||b[k][l][h]=='.')ans++;
						}
                    }
					if(ans==y*y)s=true;
					if(s)break;
				}
			}
		}
		if(s)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}
2024/12/18 16:54
加载中...