Submission #1296022

#TimeUsernameProblemLanguageResultExecution timeMemory
1296022NHristovSquare or Rectangle? (NOI19_squarerect)C++20
100 / 100
1 ms340 KiB
#include "squarerect.h" #include <bits/stdc++.h> using namespace std; bool ins(int x, int y) { if(x<1||y<1||x>100||y>100) return 0; return inside_shape(x, y); } bool am_i_square(int N, int Q) { int mnx=101, mny=101, mxx=0, mxy=0; for(int i=20; i<=80; i+=20) { for(int q=20; q<=80; q+=20) { if(!ins(i, q)) continue; mnx=min(mnx, i); mxx=max(mxx, i); mny=min(mny, q); mxy=max(mxy, q); } } if(mnx==101&&mny==101) { int cnt=0, fillx, filly; for(int i=20; i<=100; i+=20) if(ins(i, 100)) cnt++, fillx=i, filly=100; for(int i=20; i<=80; i+=20) if(ins(100, i)) cnt++, fillx=100, filly=i; if(cnt==0) return 0; if(cnt>1) return 0; if(fillx==100) { int l=filly-20, r=filly; while(l+2<=r) { int m=l+r>>1; if(ins(100, m)) r=m; else l=m; } return ins(100, r+19)&&!ins(100, r+20); } else { int l=fillx-20, r=fillx; while(l+2<=r) { int m=l+r>>1; if(ins(m, 100)) r=m; else l=m; } return ins(r+19, 100)&&!ins(r+20, 100); } } else { int l=mnx-20, r=mnx, up, dw, lft, rgt; while(l+2<=r) { int m=l+r>>1; if(ins(m, mny)) r=m; else l=m; } up=r; l=mxx, r=mxx+21; while(l+2<=r) { int m=l+r>>1; if(ins(m, mny)) l=m; else r=m; } dw=l; l=mny-20, r=mny; while(l+2<=r) { int m=l+r>>1; if(ins(mnx, m)) r=m; else l=m; } lft=r; int len=dw-up+1; rgt=lft+len-1; return ins(mnx, rgt)&&!ins(mnx, rgt+1); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...