Submission #839284

# Submission time Handle Problem Language Result Execution time Memory
839284 2023-08-29T15:02:45 Z epicci23 Comparing Plants (IOI20_plants) C++17
Compilation error
0 ms 0 KB
#include "bits/stdc++.h"
#include "plants.h"
using namespace std;
#define pb push_back
#define endl "\n" 
#define int long long
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int N = 200005;
int pre[N][2];
// 0 >
// 1 <
int n;
int query(int l,int r)
{
  l++;r++;
  int uz=r-l;
  if(pre[r-1][0]-pre[l-1][0]==uz) return -1;
  if(pre[r-1][1]-pre[l-1][1]==uz) return 1;
  
  int cur = pre[n][0] - pre[r-1][0] + pre[l-1][0];
  if(cur==n-r+l) return -1;
  cur = pre[n][1] - pre[r-1][1] + pre[l-1][1];
  if(cur==n-r+l) return 1;
  return 0;
}

void init(int k,vector<int> r) {
  n = sz(r);
    for(int i=1;i<=n;i++)
    {
      pre[i][0]+=pre[i-1][0];
      pre[i][1]+=pre[i-1][1];
      if(r[i-1]==0) pre[i][0]++;
      else pre[i][1]++;
    }
  return;
}

int compare_plants(int x, int y){
  return query(x,y);
}

Compilation message

/usr/bin/ld: /tmp/ccoLVpDj.o: in function `main':
grader.cpp:(.text.startup+0x2f6): undefined reference to `init(int, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: grader.cpp:(.text.startup+0x32f): undefined reference to `compare_plants(int, int)'
collect2: error: ld returned 1 exit status