Submission #1220849

#TimeUsernameProblemLanguageResultExecution timeMemory
1220849mariamtsagareliSquare or Rectangle? (NOI19_squarerect)C++17
18 / 100
0 ms328 KiB
#include "squarerect.h" #include <cstdlib> extern bool inside_shape(int,int); bool am_i_square(int n,int q){ int c=(n+1)/2,s=(n+10)/11,px=c,py=c; for(int i=1;i<=10;i++){ int t=i*s; if(t>n) t=n; if(inside_shape(c,t)){px=c;py=t;break;} } int l=1,r=px,m; while(l<r){ m=(l+r)/2; if(inside_shape(m,py)) r=m; else l=m+1; } int left=l; l=px; r=n; while(l<r){ m=(l+r+1)/2; if(inside_shape(m,py)) l=m; else r=m-1; } int right=l; l=1; r=py; while(l<r){ m=(l+r)/2; if(inside_shape(px,m)) r=m; else l=m+1; } int top=l; l=py; r=n; while(l<r){ m=(l+r+1)/2; if(inside_shape(px,m)) l=m; else r=m-1; } int bottom=l; return (right-left)==(bottom-top); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...