2ms,什么水平

#include <cstdio>
#include <iostream>
#include <math.h>


//找坐标规律。设N=3,(2,0)对应放大一次后对应区域左上角为(6,0),(1,1)对应(3,3),(2,1)对应(6,3),成功找到规律! 
//每放大一次,在指引到的"左上角"处生成一个最低阶(N*N)的小图。 



void Repeater(void){
	int N;
	char ctmp;
	while(scanf("%d",&N) != EOF){
		if ( N<3 || N>5 ){
			break;
		}
		int cnt = N+1;
		int a1[N*N];
		char dupjudge;
		int dj = 0;
		for (int i=0; i<N; i++){
			for (int j=0; j<N; j++){
				a1[i*N+j]= 0;
			}
		}
		scanf("%c",&ctmp);
		for (int i=0; i<N; i++){//初始化0-1标记矩阵 
			while(cnt--){
				scanf("%c",&ctmp);
				if(cnt){
					if (ctmp != ' '){
						if (!dj){
							dupjudge = ctmp;
							dj++;
						}else if (dupjudge != ctmp){
							printf("Error!\n");
							return;
						}
						a1[i*N+N-cnt] = 1;
					}
				}
			}
			cnt = N+1;
			if (ctmp != '\n'){
				printf("Error!\n");
				return;
			}
		}//此时手里有dupjudge,模板,0-1标记矩阵	
		int jieshu;
		scanf("%d",&jieshu);//放大至的最终阶数设置。注意保证一张图大小上限3000*3000
		int finalsize = pow(N, jieshu);
		if (finalsize > 3000 || jieshu <= 0){
			printf("Error!\n");
			return;
		} 
		//放大0-1标记矩阵 
//		int *afin = a1;
		int afin[finalsize*finalsize];//开始变化地yy afin的形状 
		for (int i=0; i<N; i++){
			for (int j=0; j<N; j++){
				afin[i*N+j]= a1[i*N+j];
			}
		}
		int sizea = N;
		while(--jieshu){
			int S = sizea * N;
			{
				int ans[S*S];
				for (int i=0; i<S; i++){
					for (int j=0; j<S; j++){
						ans[i*S+j] = 0;
					}
				}
				int iz,jz;//找到的左上角的坐标 
				for (int i=0; i<sizea; i++){
					for (int j=0; j<sizea; j++){
						if(afin[i*sizea+j]){//则执行"生成小图"操作 
							iz = i*N;
							jz = j*N;
							for (int ii=0; ii<N; ii++){
								for (int jj=0; jj<N; jj++){
									ans[(iz+ii)*S+(jz+jj)] = a1[ii*N+jj];
								}
							}
						}
					}
				}
//				afin = ans;
				for (int i=0; i<S; i++){
					for (int j=0; j<S; j++){
						afin[i*S+j]= ans[i*S+j];
					}
				}
			}
			sizea *= N;
		}
	
		for (int i=0; i<finalsize; i++){
			for (int j=0; j<finalsize; j++){
				if( afin[i*finalsize + j] ){
					printf("%c",dupjudge);
				}else{
					printf(" ");
				}
			}
			printf("\n");
		}
	}
	return;
}


int main(){
	Repeater();//我超,成功了,太帅了 
	return 0;
}