Submission #676094

# Submission time Handle Problem Language Result Execution time Memory
676094 2022-12-29T10:33:33 Z ghostwriter Bubble Sort 2 (JOI18_bubblesort2) C++17
38 / 100
1463 ms 1928 KB
#include "bubblesort2.h"
// #pragma GCC optimize ("Ofast")
// #pragma GCC target ("avx2")
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
    #include <debug.h>
	#include "grader.cpp"
#else
    #define debug(...)
#endif
#define ft front
#define bk back
#define st first
#define nd second
#define ins insert
#define ers erase
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define bg begin
#define ed end
#define all(x) (x).bg(), (x).ed()
#define sz(x) (int)(x).size()
// #define int long long
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
#define FOR(i, l, r) for (int i = (l); i <= (r); ++i)
#define FOS(i, r, l) for (int i = (r); i >= (l); --i)
#define FRN(i, n) for (int i = 0; i < (n); ++i)
#define FSN(i, n) for (int i = (n) - 1; i >= 0; --i)
#define EACH(i, x) for (auto &i : (x))
#define WHILE while
template<typename T> T gcd(T a, T b) { T d2 = (a | b) & -(a | b); a /= d2; b /= d2; WHILE(b) { a = a % b; swap(a, b); } return a * d2; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
void _assert(bool statement) { if (statement) return; cerr << "\n>> Assertion failed!\n"; exit(0); }
void _assert(bool statement, const str &message) { if (statement) return; cerr << "\n>> Assertion failed: " << message << '\n'; exit(0); }
void _error(const str &message) { cerr << "\n>> Error: " << message << '\n'; exit(0); }
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
----------------------------------------------------------------
    END OF TEMPLATE
----------------------------------------------------------------
    Tran The Bao - ghostwriter
    Training for VOI23 gold medal
----------------------------------------------------------------
    GOAT
----------------------------------------------------------------
*/
namespace subtask12 {
	const int MAXN = 16000;
	int N, Q;
	vi A, X, V, d[MAXN];
	bool checkCondition(vi A, vi X, vi V) {
		subtask12::A = A;
		subtask12::X = X;
		subtask12::V = V;
		return sz(A) <= 8000 && sz(X) <= 8000;
	}
	void compress() {
		vi A1;
		EACH(i, A) A1.pb(i);
		EACH(i, V) A1.pb(i);
		sort(all(A1));
		EACH(i, A) i = lb(all(A1), i) - A1.bg();
		EACH(i, V) i = lb(all(A1), i) - A1.bg();
	}
	int solve() {
		int rs = 0, maxx = 0, num = N;
		FRN(i, N) d[A[i]].pb(i);
		FRN(i, MAXN) {
			if (d[i].empty()) continue;
			EACH(j, d[i]) {
				rs = max(rs, num - N + max(maxx, j));
				--num;
				maxx = max(maxx, j);
			}
			d[i].clear();
		}
		return rs;
	}
	vi countScans() {
		N = sz(A);
		Q = sz(X);
		compress();
		vi ANS(Q);
		FRN(j, Q) {
			A[X[j]] = V[j];
			ANS[j] = solve();
		}
		return ANS;
	}
}
std::vector<int> countScans(std::vector<int> A,std::vector<int> X,std::vector<int> V){
	if (subtask12::checkCondition(A, X, V)) return subtask12::countScans();
	return vi(0, 0);
}
/*
4 2
1 2 3 4
0 3
2 1
*/
# Verdict Execution time Memory Grader output
1 Correct 18 ms 724 KB Output is correct
2 Correct 27 ms 756 KB Output is correct
3 Correct 95 ms 828 KB Output is correct
4 Correct 100 ms 832 KB Output is correct
5 Correct 94 ms 828 KB Output is correct
6 Correct 78 ms 828 KB Output is correct
7 Correct 85 ms 824 KB Output is correct
8 Correct 90 ms 844 KB Output is correct
9 Correct 96 ms 824 KB Output is correct
10 Correct 82 ms 832 KB Output is correct
11 Correct 87 ms 836 KB Output is correct
12 Correct 82 ms 828 KB Output is correct
13 Correct 82 ms 844 KB Output is correct
14 Correct 86 ms 832 KB Output is correct
15 Correct 89 ms 828 KB Output is correct
16 Correct 88 ms 952 KB Output is correct
17 Correct 81 ms 828 KB Output is correct
18 Correct 102 ms 828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 724 KB Output is correct
2 Correct 27 ms 756 KB Output is correct
3 Correct 95 ms 828 KB Output is correct
4 Correct 100 ms 832 KB Output is correct
5 Correct 94 ms 828 KB Output is correct
6 Correct 78 ms 828 KB Output is correct
7 Correct 85 ms 824 KB Output is correct
8 Correct 90 ms 844 KB Output is correct
9 Correct 96 ms 824 KB Output is correct
10 Correct 82 ms 832 KB Output is correct
11 Correct 87 ms 836 KB Output is correct
12 Correct 82 ms 828 KB Output is correct
13 Correct 82 ms 844 KB Output is correct
14 Correct 86 ms 832 KB Output is correct
15 Correct 89 ms 828 KB Output is correct
16 Correct 88 ms 952 KB Output is correct
17 Correct 81 ms 828 KB Output is correct
18 Correct 102 ms 828 KB Output is correct
19 Correct 1091 ms 1472 KB Output is correct
20 Correct 1463 ms 1684 KB Output is correct
21 Correct 1119 ms 1812 KB Output is correct
22 Correct 1369 ms 1780 KB Output is correct
23 Correct 1112 ms 1844 KB Output is correct
24 Correct 1088 ms 1600 KB Output is correct
25 Correct 1092 ms 1572 KB Output is correct
26 Correct 1094 ms 1652 KB Output is correct
27 Correct 1088 ms 1764 KB Output is correct
28 Correct 1084 ms 1928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 724 KB Output is correct
2 Correct 27 ms 756 KB Output is correct
3 Correct 95 ms 828 KB Output is correct
4 Correct 100 ms 832 KB Output is correct
5 Correct 94 ms 828 KB Output is correct
6 Correct 78 ms 828 KB Output is correct
7 Correct 85 ms 824 KB Output is correct
8 Correct 90 ms 844 KB Output is correct
9 Correct 96 ms 824 KB Output is correct
10 Correct 82 ms 832 KB Output is correct
11 Correct 87 ms 836 KB Output is correct
12 Correct 82 ms 828 KB Output is correct
13 Correct 82 ms 844 KB Output is correct
14 Correct 86 ms 832 KB Output is correct
15 Correct 89 ms 828 KB Output is correct
16 Correct 88 ms 952 KB Output is correct
17 Correct 81 ms 828 KB Output is correct
18 Correct 102 ms 828 KB Output is correct
19 Correct 1091 ms 1472 KB Output is correct
20 Correct 1463 ms 1684 KB Output is correct
21 Correct 1119 ms 1812 KB Output is correct
22 Correct 1369 ms 1780 KB Output is correct
23 Correct 1112 ms 1844 KB Output is correct
24 Correct 1088 ms 1600 KB Output is correct
25 Correct 1092 ms 1572 KB Output is correct
26 Correct 1094 ms 1652 KB Output is correct
27 Correct 1088 ms 1764 KB Output is correct
28 Correct 1084 ms 1928 KB Output is correct
29 Incorrect 3 ms 1108 KB Output isn't correct
30 Halted 0 ms 0 KB -