제출 #1216239

#제출 시각아이디문제언어결과실행 시간메모리
1216239DzadzoSquare or Rectangle? (NOI19_squarerect)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "squarerect.h"

#define ll long long
// #define int ll
#define pb push_back
#define S second
#define F first
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vp vector<pii>
#define vvp vector<vp>
#define vb vector<bool>
#define vvb vector<vb>
#define INF INT_MAX
#define MOD 1000000007
#define MAXN 200000
using namespace std;

// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

// bool inside_shape(int x,int y){
//     cout<<x<<" "<<y<<'\n';
//     bool res;
//     cin>>res;
//     return res;
// }


int N;
bool ask(int x,int y){

    if (1<=x && x<=N && 1<=y && y<=N)return inside_shape(x,y);
    return false;
}

bool am_i_square(int n, int q) {
    N=n;
    int Rmax=0,Rmin=INF,Cmax=0,Cmin=INF;
    for (int i=20;i<=n;i+=20){
        for (int j=20;j<=n;j+=20){
            
            if (ask(i,j)){
                Rmax=max(Rmax,i);
                Cmax=max(Cmax,j);
                Cmin=min(Cmin,j);
                Rmin=min(Rmin,i);
            }
        }
    }
    if (!Rmax)return false;

    if (Rmax-Rmin != Cmax - Cmin)return false;



    int R=Rmax;
    for (int bit=4;bit>=0;bit--){
        if (R+(1<<bit) >= Rmax+20 )continue;

        if (ask(R+(1<<bit),Cmax))R+=(1<<bit);

    }
    int R=Rmin;
    for (int bit=4;bit>=0;bit--){
        if (R-(1<<bit) <= Rmin-20 )continue;

        if (ask(R-(1<<bit),Cmin))R-=(1<<bit);

    }

     int C=Cmax;
    for (int bit=4;bit>=0;bit--){
        if (C+(1<<bit) >= Cmax+20 )continue;

        if (ask(Rmax,C+(1<<bit)))C+=(1<<bit);

    }
    int C=Cmin;
    for (int bit=4;bit>=0;bit--){
        if (C-(1<<bit) <= Cmin-20 )continue;

        if (ask(Rmin,C-(1<<bit)))C-=(1<<bit);

    }





    return R-r == C-c




}
/*
signed main() {
    ios::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
    int tt;
    cin>>tt;
    while (tt--){
        int n;
        cin>>n;
        int a[n+1];
        for (int i=1;i<=n;i++)cin>>a[i];
    }
}




*/

컴파일 시 표준 에러 (stderr) 메시지

squarerect.cpp: In function 'bool am_i_square(int, int)':
squarerect.cpp:67:9: error: redeclaration of 'int R'
   67 |     int R=Rmin;
      |         ^
squarerect.cpp:60:9: note: 'int R' previously declared here
   60 |     int R=Rmax;
      |         ^
squarerect.cpp:82:9: error: redeclaration of 'int C'
   82 |     int C=Cmin;
      |         ^
squarerect.cpp:75:10: note: 'int C' previously declared here
   75 |      int C=Cmax;
      |          ^
squarerect.cpp:94:14: error: 'r' was not declared in this scope
   94 |     return R-r == C-c
      |              ^
squarerect.cpp:94:21: error: 'c' was not declared in this scope
   94 |     return R-r == C-c
      |                     ^
squarerect.cpp:94:22: error: expected ';' before '}' token
   94 |     return R-r == C-c
      |                      ^
      |                      ;
......
   99 | }
      | ~