#include <stdio.h>
#include <math.h>
// 점 (x, y)가 원 (cx, cy, r) 안에 있는지 확인한다. 결과에 따라 0 또는 1을 반환
int check(int x, int y, int cx, int cy, int r) {
int dx = x - cx;
int dy = y - cy;
return dx * dx + dy * dy < r * r;
}
int main() {
int T;
scanf("%d", &T);
while (T--) {
int x1, y1, x2, y2;
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
int n;
scanf("%d", &n);
int count = 0;
while (n--) {
int cx, cy, r;
scanf("%d %d %d", &cx, &cy, &r);
// 출발점과 도착점에 대해 각각 검사한다.
int start = check(x1, y1, cx, cy, r); //출발점의 거리를 계산한다
int end = check(x2, y2, cx, cy, r); ??도착지의 거리를 계산한다
if (start != end) count++; //둘 다 0일경우 내부이동이거나 외부이동이기에 count가 올라가지 않는다.
}
printf("%d\n", count);
}
return 0;
}
#include <stdio.h>
int main() {
int N, M;
scanf("%d %d", &N, &M);
char map[50][51]; // 문자열로 받으므로 널문자 포함
for (int i = 0; i < N; i++) {
scanf("%s", map[i]);
}
int max = 1; // 최소 정사각형 넓이는 1
for (int i = 0; i < N; i++) { // 행 시작 위치
for (int j = 0; j < M; j++) { // 열 시작 위치
for (int k = 1; i + k < N && j + k < M; k++) {
// 네 꼭짓점 비교
if (map[i][j] == map[i][j + k] &&
map[i][j] == map[i + k][j] &&
map[i][j] == map[i + k][j + k]) {
int r = k + 1;
int area = r * r;
if (area > max) {
max = area;
}
}
}
}
}
printf("%d\n", max);
return 0;
}