#include <bits/stdc++.h>
using namespace std;
#define ll long long
extern bool inside_shape(int X, int Y);
bool am_i_square(int n, int Q) {
int start_x = -1, start_y = -1;
bool found = false;
for (int i = 1; i <= n && !found; i++) {
for (int j = 1; j <= n; j++) {
if (inside_shape(i, j)) {
start_x = i;
start_y = j;
found = true;
break;
}
}
}
int l = start_x, r = n, right_x = start_x;
while (l <= r) {
int mid = (l + r) / 2;
if (inside_shape(mid, start_y)) {
right_x = mid;
l = mid + 1;
} else r = mid - 1;
}
l = 1, r = start_x;
int left_x = start_x;
while (l <= r) {
int mid = (l + r) / 2;
if (inside_shape(mid, start_y)) {
left_x = mid;
r = mid - 1;
} else l = mid + 1;
}
l = 1, r = start_y;
int top_y = start_y;
while (l <= r) {
int mid = (l + r) / 2;
if (inside_shape(start_x, mid)) {
top_y = mid;
r = mid - 1;
} else l = mid + 1;
}
l = start_y, r = n;
int bottom_y = start_y;
while (l <= r) {
int mid = (l + r) / 2;
if (inside_shape(start_x, mid)) {
bottom_y = mid;
l = mid + 1;
} else r = mid - 1;
}
int width = right_x - left_x + 1;
int height = bottom_y - top_y + 1;
return (width == height);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |