-
Notifications
You must be signed in to change notification settings - Fork 0
/
0141.cpp
56 lines (47 loc) · 813 Bytes
/
0141.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
int main(void){
int d;
cin >> d;
for(int i=0;i<d;i++){
int n;
cin >> n;
bool sharp[n+4][n+4];
memset(sharp, true,sizeof(sharp));
for(int p=1;p<=n+2;p++){
for(int q=0;q<=n+2;q++){
sharp[p][q] = false;
}
}
int x=n+1,y=2;
int vec=0;
int cnt=0;
if(i) cout << endl;
while(1){
sharp[x][y] = true;
if(sharp[x+dx[vec]*2][y+dy[vec]*2]){
if(cnt > 0) break;
cnt = 2;
vec = (vec+1)%4;
}else{
x += dx[vec];
y += dy[vec];
cnt--;
}
}
for(int p=2;p<n+2;p++){
for(int q=2;q<n+2;q++){
if(sharp[p][q]){
cout << "#";
}else{
cout << " ";
}
}
cout << endl;
}
}
}