# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
317340 | 2020-10-29T14:35:45 Z | sebinkim | Square or Rectangle? (NOI19_squarerect) | C++14 | 0 ms | 0 KB |
#include "squarerect.h" #include <bits/stdc++.h> using namespace std; bool am_i_square(int N) { auto ask = [&](int x, int y){ if(x < 1 || x > N || y < 1 || y > N) return false; else return inside_shape(x, y); }; int i, j, a, b, c, d; a = b = N; c = d = 1; for(i = 20; i < 100; i += 20){ for(j = 20; j < 100; j += 20){ if(ask(i, j)){ a = min(a, i); b = min(b, j); c = max(c, i); d = max(d, j); } } } if(a == N){ for(i = 20; i <= 100; i += 20){ if(ask(i, N)){ a = i; break; } if(ask(N, i)){ b = i; break; } } for(; a != N && ask(a + 1, b); a ++); for(; b != N && ask(a, b + 1); b ++); return ask(a - 19, b - 19) && !ask(a - 19, b - 20) && !ask(a - 20, b - 19) && !ask(a - 20, b - 20); } else{ for(i = 16; i >= 1; i >>= 1){ if(ask(a - i, b)) a -= i; if(ask(a, b - i)) b -= i; if(ask(c + i, b)) c += i; } return ask(a, c - a + b) && !ask(a, c - a + b + 1); } }