Submission #964809

# Submission time Handle Problem Language Result Execution time Memory
964809 2024-04-17T15:26:02 Z Trisanu_Das Dancing Elephants (IOI11_elephants) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll l, a[150005], a_[150005];
int n;

void init(int N, int L, int X[]){
  n = N; l = L;
  a_[0] = INT_MIN, a_[n + 1] = INT_MAX;
  for(int i = 0; i < n; i++) a_[i + 1] = a[i] = X[i];
}

int update(int idx, ll val){
  int i = 0;
  while(a_[i] != a[idx]) ++i;
  a_[i] = a[idx] = val;
  while(a_[i - 1] > a_[i]) swap(a_[i - 1], a_[i]), i--;
  while(a_[i + 1] < a_[i]) swap(a_[i + 1], a_[i]); i++;
  int ans = 1; ll last = a_[1];
  for(int i = 2; i <= n; i++)
    if(a_[i] - last > l) ++ans, last = a_[i];
  
  return ans;
}

Compilation message

elephants.cpp: In function 'int update(int, long long int)':
elephants.cpp:19:3: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   19 |   while(a_[i + 1] < a_[i]) swap(a_[i + 1], a_[i]); i++;
      |   ^~~~~
elephants.cpp:19:52: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   19 |   while(a_[i + 1] < a_[i]) swap(a_[i + 1], a_[i]); i++;
      |                                                    ^
/usr/bin/ld: /tmp/ccdDmSVz.o: in function `main':
grader.cpp:(.text.startup+0x56): undefined reference to `update(int, int)'
collect2: error: ld returned 1 exit status