답안 #883270

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
883270 2023-12-05T02:39:44 Z tosivanmak Aliens (IOI07_aliens) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long

#ifdef __cplusplus
extern "C" {
#endif
int examine(int X, int Y);
void solution(int XC, int YC);
void findCenter(int N, int X0, int Y0);
#ifdef __cplusplus
}
#endif

// TODO: global variables can be declared here

ll find_coor_x(ll N, ll X0, ll Y0, ll mul){
    ll curx=X0,cury=Y0;
  bool ok=true;
  ll searchl,searchr;
  for(int i=0;i<=29;i++){
          if(curx>N||!ok||curx<1){
              searchl=curx-(((1<<(i-1)))*mul);
              searchr=curx;
              if(searchr>N){
                  searchr=N;
              }
              break;
          }
          curx+=((1<<i)*mul);
       ok=examine(curx,cury);
  }
  if(mul==-1){
      swap(searchl,searchr);
  }
  while(searchl<=searchr){
      if(searchl==searchr){
          break;
      }
      else if(searchl==searchr-1){
          if(mul==-1){
              if(examine(searchl,cury)){
                  searchr=searchl;
              }
              else{
                  searchl=searchr;
              }
          }
          else{
          if(examine(searchr,cury)){
              searchl=searchr;
          }
          else{
              searchr=searchl;
              break;
          }
          }
          break;
      }
      else{
          ll mid=(searchl+searchr)>>1;
          if(mul==-1){
              if(examine(mid,cury)){
                  searchr=mid;
              }
              else{
                  searchl=mid;
              }
          }
          else{
          if(examine(mid,cury)){
              searchl=mid;
          }
          else{
              searchr=mid;
          }
          }
      }
  }
  return searchl;
}
ll find_coor_y(ll N, ll X0, ll Y0, ll mul){
    ll curx=X0,cury=Y0;
  bool ok=true;
  ll searchl,searchr;
  for(int i=0;i<=29;i++){
          if(cury>N||!ok||cury<1){
              searchl=cury-(((1<<(i-1)))*mul);
              searchr=cury;
              if(searchr>N){
                  searchr=N;
              }
              break;
          }
          cury+=((1<<i)*mul);
       ok=examine(curx,cury);
  }
  if(mul==-1){
      swap(searchl,searchr);
  }
   while(searchl<=searchr){
      if(searchl==searchr){
          break;
      }
      else if(searchl==searchr-1){
          if(mul==-1){
              if(examine(curx,searchl)){
                  searchr=searchl;
              }
              else{
                  searchl=searchr;
              }
          }
          else{
          if(examine(curx,searchr)){
              searchl=searchr;
          }
          else{
              searchr=searchl;
              break;
          }
          }
          break;
      }
      else{
          ll mid=(searchl+searchr)>>1;
          if(mul==-1){
              if(examine(curx,mid)){
                  searchr=mid;
              }
              else{
                  searchl=mid;
              }
          }
          else{
          if(examine(curx,mid)){
              searchl=mid;
          }
          else{
              searchr=mid;
          }
          }
      }
  }
  return searchl;
}
bool ck(pair<ll,ll>coordinate, ll n){
   if(coordinate.x>n||coordinate.y>n||coordinate.x<1||coordinate.y<1){
       return false;
   }
   return examine(coordinate.x,coordinate.y);
}
struct co{
   ll x,y;
};
void findCenter(int N, int X0, int Y0) {
  // TODO: implementation
  ll xl=find_coor_x(N,X0,Y0,-1);
  ll xr=find_coor_x(N,X0,Y0,1);
  ll yl=find_coor_y(N,X0,Y0,-1);
  ll yr=find_coor_y(N,X0,Y0,1);
  co middle={(xl+xr)/2,(yl+yr)/2};
  ll M=(xr-xl+1);
  co ans;
  if(ck({middle.x+2*M,middle.y})){
      if(ck({middle.x+4*M,middle.y})){
          ans={middle.x+2*M,middle.y};
      }
      else{
          ans=middle;
      }
  }
  else{
     ans={middle.x-2*M,middle.Y};
  }
  if(ck({middle.x,middle.y+2*M})){
     if(ck({middle.x,middle.y+4*M})){
         ans.y=middle.y+2*M;
     }
     else{
         ans.y=middle.y;
     }
  }
  else{
      ans.y=middle.y-2*M;
  }
  solution(ans.x,ans.y);
}

Compilation message

aliens.cpp: In function 'bool ck(std::pair<long long int, long long int>, long long int)':
aliens.cpp:148:18: error: 'struct std::pair<long long int, long long int>' has no member named 'x'
  148 |    if(coordinate.x>n||coordinate.y>n||coordinate.x<1||coordinate.y<1){
      |                  ^
aliens.cpp:148:34: error: 'struct std::pair<long long int, long long int>' has no member named 'y'
  148 |    if(coordinate.x>n||coordinate.y>n||coordinate.x<1||coordinate.y<1){
      |                                  ^
aliens.cpp:148:50: error: 'struct std::pair<long long int, long long int>' has no member named 'x'
  148 |    if(coordinate.x>n||coordinate.y>n||coordinate.x<1||coordinate.y<1){
      |                                                  ^
aliens.cpp:148:66: error: 'struct std::pair<long long int, long long int>' has no member named 'y'
  148 |    if(coordinate.x>n||coordinate.y>n||coordinate.x<1||coordinate.y<1){
      |                                                                  ^
aliens.cpp:151:30: error: 'struct std::pair<long long int, long long int>' has no member named 'x'
  151 |    return examine(coordinate.x,coordinate.y);
      |                              ^
aliens.cpp:151:43: error: 'struct std::pair<long long int, long long int>' has no member named 'y'
  151 |    return examine(coordinate.x,coordinate.y);
      |                                           ^
aliens.cpp: In function 'void findCenter(int, int, int)':
aliens.cpp:165:32: error: too few arguments to function 'bool ck(std::pair<long long int, long long int>, long long int)'
  165 |   if(ck({middle.x+2*M,middle.y})){
      |                                ^
aliens.cpp:147:6: note: declared here
  147 | bool ck(pair<ll,ll>coordinate, ll n){
      |      ^~
aliens.cpp:166:36: error: too few arguments to function 'bool ck(std::pair<long long int, long long int>, long long int)'
  166 |       if(ck({middle.x+4*M,middle.y})){
      |                                    ^
aliens.cpp:147:6: note: declared here
  147 | bool ck(pair<ll,ll>coordinate, ll n){
      |      ^~
aliens.cpp:174:31: error: 'struct co' has no member named 'Y'
  174 |      ans={middle.x-2*M,middle.Y};
      |                               ^
aliens.cpp:174:32: error: no match for 'operator=' (operand types are 'co' and '<brace-enclosed initializer list>')
  174 |      ans={middle.x-2*M,middle.Y};
      |                                ^
aliens.cpp:153:8: note: candidate: 'constexpr co& co::operator=(const co&)'
  153 | struct co{
      |        ^~
aliens.cpp:153:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const co&'
aliens.cpp:153:8: note: candidate: 'constexpr co& co::operator=(co&&)'
aliens.cpp:153:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'co&&'
aliens.cpp:176:32: error: too few arguments to function 'bool ck(std::pair<long long int, long long int>, long long int)'
  176 |   if(ck({middle.x,middle.y+2*M})){
      |                                ^
aliens.cpp:147:6: note: declared here
  147 | bool ck(pair<ll,ll>coordinate, ll n){
      |      ^~
aliens.cpp:177:35: error: too few arguments to function 'bool ck(std::pair<long long int, long long int>, long long int)'
  177 |      if(ck({middle.x,middle.y+4*M})){
      |                                   ^
aliens.cpp:147:6: note: declared here
  147 | bool ck(pair<ll,ll>coordinate, ll n){
      |      ^~