Submission #1213569

#TimeUsernameProblemLanguageResultExecution timeMemory
1213569exoworldgdSquare or Rectangle? (NOI19_squarerect)C++20
Compilation error
0 ms0 KiB
#include "squarerect.h" #include <bits/stdc++.h> using namespace std; bool ask(int i, int j) {return inside_shape(i,j);} bool am_i_square(int n, int q) { int t=1,b=n,l=1,r=n,lo=1,hi=n; while (lo < hi) { int m = lo+(hi-lo)/2,yes=0; for (i = 1; i<= n; i++) if (ask(m,i)) {yes=1; break;} if (yes) hi = m; else lo=m+1; } t=lo, lo= t, hi=n; while (lo < hi) { int m = lo+(hi-lo)/2,yes=0; for (i = 1; i<= n; i++) if (ask(m,i)) {yes=1; break;} if (yes) lo = m; else hi=m-1; } b=lo; lo = 1, hi = n; while (lo < hi) { int m = lo+(hi-lo)/2,yes=0; for (int i = t; i <= b; i++) if (ask(i,m)) { yes = 1; break; } if (yes) hi = m; else lo = m+1; } l = lo, lo = l, hi=n; while (lo < hi) { int m = lo+(hi-lo)/2,yes=0; for (int i = t; i <= b; i++) if (ask(i,m)) { yes = 1; break; } if (yes) lo = m; else hi = m-1; } r=lo; int l=b-t+1,w=r-l+1; return w == l; }

Compilation message (stderr)

squarerect.cpp: In function 'bool am_i_square(int, int)':
squarerect.cpp:9:22: error: 'i' was not declared in this scope
    9 |                 for (i = 1; i<= n; i++) if (ask(m,i)) {yes=1; break;}
      |                      ^
squarerect.cpp:16:22: error: 'i' was not declared in this scope
   16 |                 for (i = 1; i<= n; i++) if (ask(m,i)) {yes=1; break;}
      |                      ^
squarerect.cpp:36:9: error: redeclaration of 'int l'
   36 |     int l=b-t+1,w=r-l+1;
      |         ^
squarerect.cpp:6:21: note: 'int l' previously declared here
    6 |         int t=1,b=n,l=1,r=n,lo=1,hi=n;
      |                     ^