#include #include #include static char map[256][256]; // Map with [y][x] coordinates static int w,h; // Map size struct antena { struct antena *next; // Linked list, an elegant weapon int x,y; }; static int add_antinode(struct antena *a, struct antena *b) { int x = a->x + a->x - b->x; int y = a->y + a->y - b->y; if (x>=0 && x=0 && ynext = 0; child->x = x; child->y = y; if (antenas[c]) { for (node = antenas[c]; node->next; node = node->next); node->next = child; } else { antenas[c] = child; } } // Place antinodes for each antena type pair and sum the result result = 0; for (c=0; c<128; c++) { for (node = antenas[c]; node && node->next; node = node->next) for (child = node->next; child; child = child->next) { result += add_antinode(node, child); result += add_antinode(child, node); } } printf("%d\n", result); return 0; }