7 void debug(const char *fmt
, ...) {
11 vfprintf(stderr
, fmt
, ap
);
18 short array
[LIMIT
][LIMIT
];
21 static void process(const char *str
) {
24 if (sscanf(str
, "#%d @ %d,%d: %dx%d\n", &a
, &b
, &c
, &d
, &e
) != 5) {
25 printf("bad input!\n");
28 if (b
+ d
> LIMIT
|| c
+ e
> LIMIT
) {
29 printf("recompile with larger LIMIT!\n");
32 debug("processing #%d %d,%d: %dx%d\n", a
, b
, c
, d
, e
);
33 for (i
= b
; i
< b
+ d
; i
++)
34 for (j
= c
; j
< c
+ e
; j
++) {
36 list
[a
] = list
[array
[j
][i
]] = 1;
42 int main(int argc
, char **argv
) {
43 size_t len
= 0, count
= 0;
48 if (!(stdin
= freopen(argv
[1], "r", stdin
))) {
53 while (getline(&line
, &len
, stdin
) >= 0) {
57 printf("read %zd lines\n", count
);
59 for (i
= 0; i
< LIMIT
; i
++)
60 for (j
= 0; j
< LIMIT
; j
++) {
61 debug("%d %d %d\n", i
, j
, array
[j
][i
]);
65 printf("found %zd overlaps\n", count
);
66 for (i
= 1; i
< sizeof list
; i
++)
69 printf("unique claim %d\n", i
);