Submission #676096

#TimeUsernameProblemLanguageResultExecution timeMemory
676096ghostwriterBubble Sort 2 (JOI18_bubblesort2)C++17
38 / 100
1467 ms1744 KiB
#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 + 1); } 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...