50003. Turtle Graphics
難度:4/5 Used Time: 43:081
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int x, y, l;
int map[105][105];
bool flag = false;
static inline int max(int a, int b){
if(a > b) return a;
else return b;
}
static inline int min(int a, int b){
if(a < b) return a;
else return b;
}
static inline int this_abs(int n){
if(n < 0) return -n;
else return n;
}
static inline void ipt(){
scanf("%d %d %d", &l, &y, &x);
for(int i = 0; i < x; i++) for(int j = 0; j < y; j++){
map[i][j] = 0;
}
}
static inline void opt_error(int line_num, int point_num){
printf("ERROR %d %d\n", line_num, point_num);
flag = true;
return;
}
static inline bool is_valid(int this_x, int this_y){
if((this_x >= 0 && this_x < x) && (this_y >= 0 && this_y < y)) return true;
else return false;
}
static inline void update(int line_num){
int n, old_x, old_y, now_x, now_y;
scanf("%d", &n);
scanf("%d %d", &old_x, &old_y);
if(!is_valid(old_x, old_y)){
opt_error(line_num + 1, 1);
return;
}
for(int i = 1; i < n; i++){
scanf("%d %d", &now_x, &now_y);
if(!is_valid(now_x, now_y)){
opt_error(line_num + 1, i + 1);
return;
}
if(old_x == now_x){
for(int i = min(old_y, now_y); i <= max(old_y, now_y); i++){
map[old_x][i] = 1;
}
}
else if(old_y == now_y){
for(int i = min(old_x, now_x); i <= max(old_x, now_x); i++){
map[i][old_y] = 1;
}
}
else if(this_abs(old_x - now_x) == this_abs(old_y - now_y)){
int d = this_abs(old_x - now_x);
int ptr_x = old_x, ptr_y = old_y;
int d_x, d_y;
if(old_x < now_x) d_x = 1;
else d_x = -1;
if(old_y < now_y) d_y = 1;
else d_y = -1;
for(int i = 0; i <= d; i++){
map[ptr_x][ptr_y] = 1;
ptr_x += d_x;
ptr_y += d_y;
}
}
else{
opt_error(line_num + 1, i + 1);
return;
}
old_x = now_x; old_y = now_y;
}
}
int main(){
ipt();
for(int i = 0; i < l; i++){
update(i);
if(flag) return 0;
}
for(int j = y - 1; j >= 0; j--){
for(int i = 0; i < x; i++){
printf("%d", map[i][j]);
}
printf("\n");
}
}