Submission #676098

# Submission time Handle Problem Language Result Execution time Memory
676098 2022-12-29T10:40:59 Z ghostwriter Bubble Sort 2 (JOI18_bubblesort2) C++17
38 / 100
1499 ms 1712 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 = -1, 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 + 1, 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 16 ms 724 KB Output is correct
2 Correct 28 ms 760 KB Output is correct
3 Correct 97 ms 824 KB Output is correct
4 Correct 100 ms 832 KB Output is correct
5 Correct 93 ms 832 KB Output is correct
6 Correct 86 ms 948 KB Output is correct
7 Correct 86 ms 852 KB Output is correct
8 Correct 87 ms 832 KB Output is correct
9 Correct 94 ms 856 KB Output is correct
10 Correct 86 ms 832 KB Output is correct
11 Correct 82 ms 832 KB Output is correct
12 Correct 84 ms 832 KB Output is correct
13 Correct 87 ms 820 KB Output is correct
14 Correct 90 ms 832 KB Output is correct
15 Correct 81 ms 832 KB Output is correct
16 Correct 91 ms 824 KB Output is correct
17 Correct 104 ms 724 KB Output is correct
18 Correct 93 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 724 KB Output is correct
2 Correct 28 ms 760 KB Output is correct
3 Correct 97 ms 824 KB Output is correct
4 Correct 100 ms 832 KB Output is correct
5 Correct 93 ms 832 KB Output is correct
6 Correct 86 ms 948 KB Output is correct
7 Correct 86 ms 852 KB Output is correct
8 Correct 87 ms 832 KB Output is correct
9 Correct 94 ms 856 KB Output is correct
10 Correct 86 ms 832 KB Output is correct
11 Correct 82 ms 832 KB Output is correct
12 Correct 84 ms 832 KB Output is correct
13 Correct 87 ms 820 KB Output is correct
14 Correct 90 ms 832 KB Output is correct
15 Correct 81 ms 832 KB Output is correct
16 Correct 91 ms 824 KB Output is correct
17 Correct 104 ms 724 KB Output is correct
18 Correct 93 ms 844 KB Output is correct
19 Correct 1131 ms 1456 KB Output is correct
20 Correct 1499 ms 1660 KB Output is correct
21 Correct 1162 ms 1712 KB Output is correct
22 Correct 1422 ms 1640 KB Output is correct
23 Correct 1146 ms 1524 KB Output is correct
24 Correct 1132 ms 1532 KB Output is correct
25 Correct 1114 ms 1472 KB Output is correct
26 Correct 1129 ms 1380 KB Output is correct
27 Correct 1108 ms 1516 KB Output is correct
28 Correct 1129 ms 1424 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 16 ms 724 KB Output is correct
2 Correct 28 ms 760 KB Output is correct
3 Correct 97 ms 824 KB Output is correct
4 Correct 100 ms 832 KB Output is correct
5 Correct 93 ms 832 KB Output is correct
6 Correct 86 ms 948 KB Output is correct
7 Correct 86 ms 852 KB Output is correct
8 Correct 87 ms 832 KB Output is correct
9 Correct 94 ms 856 KB Output is correct
10 Correct 86 ms 832 KB Output is correct
11 Correct 82 ms 832 KB Output is correct
12 Correct 84 ms 832 KB Output is correct
13 Correct 87 ms 820 KB Output is correct
14 Correct 90 ms 832 KB Output is correct
15 Correct 81 ms 832 KB Output is correct
16 Correct 91 ms 824 KB Output is correct
17 Correct 104 ms 724 KB Output is correct
18 Correct 93 ms 844 KB Output is correct
19 Correct 1131 ms 1456 KB Output is correct
20 Correct 1499 ms 1660 KB Output is correct
21 Correct 1162 ms 1712 KB Output is correct
22 Correct 1422 ms 1640 KB Output is correct
23 Correct 1146 ms 1524 KB Output is correct
24 Correct 1132 ms 1532 KB Output is correct
25 Correct 1114 ms 1472 KB Output is correct
26 Correct 1129 ms 1380 KB Output is correct
27 Correct 1108 ms 1516 KB Output is correct
28 Correct 1129 ms 1424 KB Output is correct
29 Incorrect 3 ms 1108 KB Output isn't correct
30 Halted 0 ms 0 KB -