Submission #883268

# Submission time Handle Problem Language Result Execution time Memory
883268 2023-12-05T02:38:48 Z tosivanmak Aliens (IOI07_aliens) C++17
Compilation error
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);
  pair<ll,ll>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:170:15: error: no match for 'operator=' (operand types are 'std::pair<long long int, long long int>' and 'co')
  170 |           ans=middle;
      |               ^~~~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:390:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type) [with _T1 = long long int; _T2 = long long int; typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type = const std::pair<long long int, long long int>&]'
  390 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:393:41: note:   no known conversion for argument 1 from 'co' to 'std::conditional<true, const std::pair<long long int, long long int>&, const std::__nonesuch&>::type' {aka 'const std::pair<long long int, long long int>&'}
  390 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~    
  391 |   __and_<is_copy_assignable<_T1>,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        
  392 |          is_copy_assignable<_T2>>::value,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  393 |   const pair&, const __nonesuch&>::type __p)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_pair.h:401:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type) [with _T1 = long long int; _T2 = long long int; typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type = std::pair<long long int, long long int>&&]'
  401 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:404:31: note:   no known conversion for argument 1 from 'co' to 'std::conditional<true, std::pair<long long int, long long int>&&, std::__nonesuch&&>::type' {aka 'std::pair<long long int, long long int>&&'}
  401 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~
  402 |   __and_<is_move_assignable<_T1>,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  403 |          is_move_assignable<_T2>>::value,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  404 |   pair&&, __nonesuch&&>::type __p)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_pair.h:418:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = long long int; _T2 = long long int]'
  418 |  operator=(const pair<_U1, _U2>& __p)
      |  ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:418:2: note:   template argument deduction/substitution failed:
aliens.cpp:170:15: note:   'co' is not derived from 'const std::pair<_T1, _T2>'
  170 |           ans=middle;
      |               ^~~~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:430:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = long long int; _T2 = long long int]'
  430 |  operator=(pair<_U1, _U2>&& __p)
      |  ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:430:2: note:   template argument deduction/substitution failed:
aliens.cpp:170:15: note:   'co' is not derived from 'std::pair<_T1, _T2>'
  170 |           ans=middle;
      |               ^~~~~~
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 'std::pair<long long int, long long int>' and '<brace-enclosed initializer list>')
  174 |      ans={middle.x-2*M,middle.Y}
      |                                ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:390:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type) [with _T1 = long long int; _T2 = long long int; typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type = const std::pair<long long int, long long int>&]'
  390 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:393:41: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::conditional<true, const std::pair<long long int, long long int>&, const std::__nonesuch&>::type' {aka 'const std::pair<long long int, long long int>&'}
  390 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~    
  391 |   __and_<is_copy_assignable<_T1>,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        
  392 |          is_copy_assignable<_T2>>::value,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  393 |   const pair&, const __nonesuch&>::type __p)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_pair.h:401:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type) [with _T1 = long long int; _T2 = long long int; typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type = std::pair<long long int, long long int>&&]'
  401 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:404:31: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::conditional<true, std::pair<long long int, long long int>&&, std::__nonesuch&&>::type' {aka 'std::pair<long long int, long long int>&&'}
  401 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~
  402 |   __and_<is_move_assignable<_T1>,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  403 |          is_move_assignable<_T2>>::value,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  404 |   pair&&, __nonesuch&&>::type __p)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_pair.h:418:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = long long int; _T2 = long long int]'
  418 |  operator=(const pair<_U1, _U2>& __p)
      |  ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:418:2: note:   template argument deduction/substitution failed:
aliens.cpp:174:32: note:   couldn't deduce template parameter '_U1'
  174 |      ans={middle.x-2*M,middle.Y}
      |                                ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:430:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = long long int; _T2 = long long int]'
  430 |  operator=(pair<_U1, _U2>&& __p)
      |  ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:430:2: note:   template argument deduction/substitution failed:
aliens.cpp:174:32: note:   couldn't deduce template parameter '_U1'
  174 |      ans={middle.x-2*M,middle.Y}
      |                                ^
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){
      |      ^~
aliens.cpp:178:14: error: 'struct std::pair<long long int, long long int>' has no member named 'y'
  178 |          ans.y=middle.y+2*M;
      |              ^
aliens.cpp:181:14: error: 'struct std::pair<long long int, long long int>' has no member named 'y'
  181 |          ans.y=middle.y;
      |              ^
aliens.cpp:185:11: error: 'struct std::pair<long long int, long long int>' has no member named 'y'
  185 |       ans.y=middle.y-2*M;
      |           ^
aliens.cpp:187:16: error: 'struct std::pair<long long int, long long int>' has no member named 'x'
  187 |   solution(ans.x,ans.y);
      |                ^
aliens.cpp:187:22: error: 'struct std::pair<long long int, long long int>' has no member named 'y'
  187 |   solution(ans.x,ans.y);
      |                      ^