Submission #890283

#TimeUsernameProblemLanguageResultExecution timeMemory
890283LucaIlieRoad Construction (JOI21_road_construction)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>   #define int long long   using namespace std;   struct point { int x, y; };   const int MAX_N = 2.5e5; const int MAX_X = 1e9; const int INF = 2e9 + 1; point v[MAX_N];   struct AIB { vector<int> pos; vector<int> aib;   void init() { pos.clear(); aib.clear(); }   void add( int i ) { pos.push_back( i ); }   void prep() { pos.push_back( -INF ); sort( pos.begin(), pos.end() ); pos.resize( unique( pos.begin(), pos.end() ) - pos.begin() ); for ( int i = 0; i < pos.size(); i++ ) aib.push_back( 0 ); }   void clear() { for ( int i = 0; i < aib.size(); i++ ) aib[i] = 0; }   void update( int i, int x ) { int l = 0, r = pos.size(); while ( r - l > 1 ) { int p = (l + r) / 2; if ( pos[p] > i ) r = p; else l = p; } if ( pos[l] != i ) exit( 1 ); i = l; while ( i < aib.size() ) { aib[i] += x; i += (i & -i); } }   int query( int i ) { int l = 0, r = pos.size(); while ( r - l > 1 ) { int p = (l + r) / 2; if ( pos[p] > i ) r = p; else l = p; } i = l; int s = 0; while ( i > 0 ) { s += aib[i]; i -= (i & -i); } return s; } };   struct AIB2D { vector<int> pos; vector<AIB> aib; vector<point> pts; AIB emptyAIB;   void init() { pos.clear(); aib.clear(); }   void add( int i, int j ) { pts.push_back( { i, j } ); pos.push_back( i ); emptyAIB.init(); }   void prep() { pos.push_back( -INF ); sort( pos.begin(), pos.end() ); pos.resize( unique( pos.begin(), pos.end() ) - pos.begin() ); for ( int i = 0; i < pos.size(); i++ ) aib.push_back( emptyAIB ); for ( point q: pts ) { int l = 0, r = pos.size(); while ( r - l > 1 ) { int p = (l + r) / 2; if ( pos[p] > q.x ) r = p; else l = p; } int i = l; while ( i < aib.size() ) { aib[i].add( q.y ); i += (i & -i); } } for ( int i = 0; i < pos.size(); i++ ) aib[i].prep(); }   void clear() { for ( int i = 0; i < aib.size(); i++ ) aib[i].clear(); }   void update( int i, int j, int x ) { int l = 0, r = pos.size(); while ( r - l > 1 ) { int p = (l + r) / 2; if ( pos[p] > i ) r = p; else l = p; } i = l; while ( i < aib.size() ) { aib[i].update( j, x ); i += (i & -i); } }   int query( int i, int j ) { int l = 0, r = pos.size(); while ( r - l > 1 ) { int p = (l + r) / 2; if ( pos[p] > i ) r = p; else l = p; } i = l; int s = 0; while ( i > 0 ) { s += aib[i].query( j ); i -= (i & -i); } return s; } } leftPoints, rightPoints;   signed main() { int n, k;   cin >> n >> k; for ( int i = 0; i < n; i++ ) cin >> v[i].x >> v[i].y;   sort( v, v + n, []( point a, point b ) { if ( a.x == b.x ) return a.y < b.y; return a.x < b.x; } );     leftPoints.init(); rightPoints.init(); for ( int i = 0; i < n; i++ ) { leftPoints.add( v[i].y, -v[i].x - v[i].y ); rightPoints.add( v[i].y, -v[i].x + v[i].y ); } leftPoints.prep(); rightPoints.prep();   int ld = 0, rd = 2 * INF; while ( rd - ld > 1 ) { int d = (ld + rd) / 2;   int pairs = 0; leftPoints.clear(); rightPoints.clear(); for ( int i = 0; i < n; i++ ) { pairs += leftPoints.query( v[i].y, d - (v[i].x + v[i].y) ); pairs += rightPoints.query( MAX_X, d - (v[i].x - v[i].y) ) - rightPoints.query( v[i].y, d - (v[i].x - v[i].y) );   leftPoints.update( v[i].y, -v[i].x - v[i].y, 1 ); rightPoints.update( v[i].y, -v[i].x + v[i].y, 1 ); }   if ( pairs < k ) ld = d; else rd = d; } int d = rd;   vector<int> sol; while ( sol.size() < k ) sol.push_back( d ); sort( sol.begin(), sol.end() ); for( int x: sol ) cout << x << "\n";   return 0; }

Compilation message (stderr)

road_construction.cpp:3:1: error: extended character   is not valid in an identifier
    3 |  
      | ^
road_construction.cpp:5:1: error: extended character   is not valid in an identifier
    5 |  
      | ^
road_construction.cpp:7:1: error: extended character   is not valid in an identifier
    7 |  
      | ^
road_construction.cpp:11:1: error: extended character   is not valid in an identifier
   11 |  
      | ^
road_construction.cpp:16:1: error: extended character   is not valid in an identifier
   16 |  
      | ^
road_construction.cpp:20:1: error: extended character   is not valid in an identifier
   20 |  
      | ^
road_construction.cpp:25:1: error: extended character   is not valid in an identifier
   25 |  
      | ^
road_construction.cpp:29:1: error: extended character   is not valid in an identifier
   29 |  
      | ^
road_construction.cpp:37:1: error: extended character   is not valid in an identifier
   37 |  
      | ^
road_construction.cpp:42:1: error: extended character   is not valid in an identifier
   42 |  
      | ^
road_construction.cpp:60:1: error: extended character   is not valid in an identifier
   60 |  
      | ^
road_construction.cpp:79:1: error: extended character   is not valid in an identifier
   79 |  
      | ^
road_construction.cpp:85:1: error: extended character   is not valid in an identifier
   85 |  
      | ^
road_construction.cpp:90:1: error: extended character   is not valid in an identifier
   90 |  
      | ^
road_construction.cpp:96:1: error: extended character   is not valid in an identifier
   96 |  
      | ^
road_construction.cpp:121:1: error: extended character   is not valid in an identifier
  121 |  
      | ^
road_construction.cpp:126:1: error: extended character   is not valid in an identifier
  126 |  
      | ^
road_construction.cpp:142:1: error: extended character   is not valid in an identifier
  142 |  
      | ^
road_construction.cpp:161:1: error: extended character   is not valid in an identifier
  161 |  
      | ^
road_construction.cpp:164:1: error: extended character   is not valid in an identifier
  164 |  
      | ^
road_construction.cpp:168:1: error: extended character   is not valid in an identifier
  168 |  
      | ^
road_construction.cpp:174:1: error: extended character   is not valid in an identifier
  174 |  
      | ^
road_construction.cpp:175:1: error: extended character   is not valid in an identifier
  175 |  
      | ^
road_construction.cpp:184:1: error: extended character   is not valid in an identifier
  184 |  
      | ^
road_construction.cpp:188:1: error: extended character   is not valid in an identifier
  188 |  
      | ^
road_construction.cpp:195:1: error: extended character   is not valid in an identifier
  195 |  
      | ^
road_construction.cpp:199:1: error: extended character   is not valid in an identifier
  199 |  
      | ^
road_construction.cpp:206:1: error: extended character   is not valid in an identifier
  206 |  
      | ^
road_construction.cpp:213:1: error: extended character   is not valid in an identifier
  213 |  
      | ^
road_construction.cpp:3:1: error: '\U000000a0' does not name a type
    3 |  
      | ^
road_construction.cpp:7:1: error: '\U000000a0' does not name a type
    7 |  
      | ^
road_construction.cpp:11:1: error: '\U000000a0' does not name a type
   11 |  
      | ^
road_construction.cpp:15:1: error: 'point' does not name a type
   15 | point v[MAX_N];
      | ^~~~~
road_construction.cpp:16:1: error: '\U000000a0' does not name a type
   16 |  
      | ^
road_construction.cpp:79:1: error: '\U000000a0' does not name a type
   79 |  
      | ^
road_construction.cpp:160:3: error: 'leftPoints' does not name a type
  160 | } leftPoints, rightPoints;
      |   ^~~~~~~~~~
road_construction.cpp:161:1: error: '\U000000a0' does not name a type
  161 |  
      | ^