Submission #72706144
Source Code Expand
Copy
#include <stdio.h>#include <stdlib.h>struct coord_s {int x, y;};int cmp(const void* x, const void* y) {struct coord_s a = *(const struct coord_s*)x, b = *(const struct coord_s*)y;if (a.y != b.y) return (a.y > b.y) - (a.y < b.y);return (a.x > b.x) - (a.x < b.x);}int m;int x[256], y[256];int n;struct coord_s hosi[1024];int exists(int x, int y) {struct coord_s target = { x, y };return !!bsearch(&target, hosi, n, sizeof(*hosi), cmp);
#include <stdio.h>
#include <stdlib.h>
struct coord_s {
int x, y;
};
int cmp(const void* x, const void* y) {
struct coord_s a = *(const struct coord_s*)x, b = *(const struct coord_s*)y;
if (a.y != b.y) return (a.y > b.y) - (a.y < b.y);
return (a.x > b.x) - (a.x < b.x);
}
int m;
int x[256], y[256];
int n;
struct coord_s hosi[1024];
int exists(int x, int y) {
struct coord_s target = { x, y };
return !!bsearch(&target, hosi, n, sizeof(*hosi), cmp);
}
int main(void) {
int i;
if (scanf("%d", &m) != 1) return 1;
for (i = 0; i < m; i++) {
if (scanf("%d%d", &x[i], &y[i]) != 2) return 1;
}
if (scanf("%d", &n) != 1) return 1;
for (i = 0; i < n; i++) {
if (scanf("%d%d", &hosi[i].x, &hosi[i].y) != 2) return 1;
}
qsort(hosi, n, sizeof(*hosi), cmp);
/* 星座の最初の星が、写真のどの星に対応するかを全探索 */
for (i = 0; i < n; i++) {
int ox = hosi[i].x - x[0], oy = hosi[i].y - y[0];
int j;
int yes = 1;
for (j = 1; j < m; j++) {
if (!exists(x[j] + ox, y[j] + oy)) {
yes = 0;
break;
}
}
if (yes) {
printf("%d %d\n", ox, oy);
return 0;
}
}
puts("NOT FOUND");
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - 星座探し |
| User | mikecat |
| Language | C23 (GCC 14.2.0) |
| Score | 100 |
| Code Size | 1205 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 1712 KiB |
Judge Result
| Set Name | set01 | set02 | set03 | set04 | set05 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 20 / 20 | 20 / 20 | 20 / 20 | 20 / 20 | 20 / 20 | ||||||||||
| Status |
|
|
|
|
|
| Set Name | Test Cases |
|---|---|
| set01 | data1 |
| set02 | data2 |
| set03 | data3 |
| set04 | data4 |
| set05 | data5 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| data1 | AC | 0 ms | 1676 KiB |
| data2 | AC | 0 ms | 1620 KiB |
| data3 | AC | 1 ms | 1544 KiB |
| data4 | AC | 1 ms | 1712 KiB |
| data5 | AC | 1 ms | 1712 KiB |