Submission #894673

# Submission time Handle Problem Language Result Execution time Memory
894673 2023-12-28T16:45:27 Z lunaTu Bubble Sort 2 (JOI18_bubblesort2) C++17
0 / 100
11 ms 4444 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#include "bubblesort2.h"
typedef long long ll;
using namespace std;

const int N = 5e4 + 1;
int A[N];
set<int> d[N];
set<int> s;

int add(int n, int i, int x) {
    d[A[i]].erase(i);
    if (d[A[i]].empty()) s.erase(A[i]);

    d[x].insert(i);
    s.insert(x);

    int mx = 0, sum = 0, p = -1;
    for (auto e : s) {
        int j = *d[e].rbegin();

        sum += d[e].size();
        if (j > p) {
            mx = max(mx, j + 1 - sum);
            p = j;
        }
    }

    return mx;
}

vector<int> countScans(vector<int> a, vector<int> x, vector<int> v) {
    int n = a.size(), q = x.size();

    vector<int> b(n + q);
    for (int i = 0; i < n; i++) {
        b[i] = a[i];
    }
    for (int i = n; i < n + q; i ++) {
        b[i] = v[i - n];
    }
    sort(all(b));

    int cnt = 1;
    map<int, int> r;
    for (auto e : b) {
        if (!r[e]) r[e] = cnt++;
    }

    for (int i = 0; i < n; i++) {
        int e = r[a[i]];
        s.insert(e);
        d[e].insert(i);
        A[i] = e;
    }

	vector<int> answer(q);

	for (int j = 0; j < q; j++) answer[j] = add(n, x[j], r[v[j]]);

	return answer;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 2908 KB Output isn't correct
2 Halted 0 ms 0 KB -