Result: Accepted
Time: 232ms
Memory: 1712kB
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
int main ()
{
int t;
scanf("%d",&t);
while (t--)
{
int n,m;
scanf("%d %d",&n,&m);
int t,c;
int a,b;
int az[20][20];
memset(az,0,sizeof(az));
for (int i = 0; i < m; i++)
{
scanf("%d %d %d %d",&t,&c,&a,&b);
if(a<0)a=0;
if(b>n)b=n-1;
if(a>n)continue;
if(b<0)continue;
if(t==2)
{
for (int j = a; j <=b; j++)
{
az[c][j]=1;
}
}
else if(t==1||t==-1||t==0)
{
for (int j = a; j <= b; j++)
{
for (int z = 0; z <n; z++)
{
if(z==t*j+c)
{
az[j][z]=1;
}
}
}
}
}
int Q;
cin>>Q;
for (int j = 0; j < n; j++)
{
for (int k = 0; k < n; k++)
{
if(az[j][k]==1)
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
while (Q--)
{
int q;
cin>>q;
for (int j = 0; j < n*q; j++)
{
for (int k = 0; k < n*q; k++)
{
if(az[(j/q)][(k/q)]==1)
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
}
}
}