Submission #1054093

# Submission time Handle Problem Language Result Execution time Memory
1054093 2024-08-12T06:15:35 Z NeroZein Bubble Sort 2 (JOI18_bubblesort2) C++17
Compilation error
0 ms 0 KB
#include "bits/stdc++.h"
using namespace std;

#ifdef Nero
#include "Deb.h"
#else
#define debug(...)
#endif

const int M = 1e5 + 5;

int tree[M];

void upd (int id, int v) {
  id++;
  while (id < M) {
    tree[id] += v;
    id += id & -id;
  }
}

int qry (int id) {
  id++;
  int ret = 0; 
  while (id) {
    ret += tree[id];
    id -= id & -id; 
  }
  return ret; 
}


int count(vector<int>& a) {
  int ret = 0;
  int n = (int) a.size();
  vector<int> ord(n);
  iota(ord.begin(), ord.end(), 0);
  sort(ord.begin(), ord.end(), [&](int i, int j) {
    return (a[ord[i]] == a[ord[j]] ? i > j : a[ord[i]] > a[ord[j]]);
  });
  for (int i : ord) {
    ret = max(ret, qry(i));
    upd(i, 1); 
  }
  for (int i = 0; i < n; ++i) {
    upd(i, -1); 
  }
  return ret; 
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, q;
  cin >> n >> q;
  vector<int> a(n); 
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  while (q--) {
    int x, v;
    cin >> x >> v;
    a[x] = v;
    cout << count(a) << '\n';
  }
  return 0;
}

Compilation message

/usr/bin/ld: /tmp/ccjFwC2s.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccT3ogFs.o:bubblesort2.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccjFwC2s.o: in function `main':
grader.cpp:(.text.startup+0x181): undefined reference to `countScans(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status