Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.1 kB
3
Indexable
Never
#include<iostream>
char a[8][8];
using namespace std;


int main(){
	//freopen("text.txt", "r", stdin);
	for(int tc=1; tc <=10; tc++){
		int n;
		cin >> n;
		for(int i=0; i <8; i++){
			for(int j=0; j <8; j++){
				cin >> a[i][j];
			}
		}
		int count=0;
			
		for(int i=0; i <8; i++){
			for(int j=0; j <= 8-n; j++){
				char *b = new char[n];
				bool check =true;
				int h=0;
				for(int k=j; k < j+n; k++){
					
					b[h] = a[i][k];
					h++;
				}
				for(int k=0;k<=n/2;k++){
					if(b[k] != b[n-1-k]){
						check =false;
						break;}
					}
				if(check == true) count++;
				delete[] b;
			}
		}

		for(int j=0; j < 8; j++){
			for(int i=0; i <= 8-n; i++){
				char *d = new char[n];
				bool check =true;
				int h=0;
				for(int k=i; k < i+n; k++){
				
					d[h] = a[k][j];
					h++;
				}
				for(int k=0;k<=n/2;k++){
					if(d[k] != d[n-1-k]){
						check =false;
						break;}			
				}
				if(check == true) count++;
				delete[] d;
			}
		}
		cout << "#" << tc << " " << count << endl;
	}
	return 0;
}