답안 #676093

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
676093 2022-12-29T10:33:02 Z ghostwriter Bubble Sort 2 (JOI18_bubblesort2) C++17
17 / 100
85 ms 1752 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 = 8000;
	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
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 468 KB Output is correct
2 Correct 19 ms 696 KB Output is correct
3 Correct 85 ms 828 KB Output is correct
4 Correct 80 ms 724 KB Output is correct
5 Correct 79 ms 708 KB Output is correct
6 Correct 64 ms 816 KB Output is correct
7 Correct 65 ms 684 KB Output is correct
8 Correct 73 ms 708 KB Output is correct
9 Correct 78 ms 676 KB Output is correct
10 Correct 71 ms 680 KB Output is correct
11 Correct 67 ms 660 KB Output is correct
12 Correct 72 ms 800 KB Output is correct
13 Correct 66 ms 672 KB Output is correct
14 Correct 65 ms 688 KB Output is correct
15 Correct 65 ms 672 KB Output is correct
16 Correct 67 ms 596 KB Output is correct
17 Correct 65 ms 676 KB Output is correct
18 Correct 85 ms 688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 468 KB Output is correct
2 Correct 19 ms 696 KB Output is correct
3 Correct 85 ms 828 KB Output is correct
4 Correct 80 ms 724 KB Output is correct
5 Correct 79 ms 708 KB Output is correct
6 Correct 64 ms 816 KB Output is correct
7 Correct 65 ms 684 KB Output is correct
8 Correct 73 ms 708 KB Output is correct
9 Correct 78 ms 676 KB Output is correct
10 Correct 71 ms 680 KB Output is correct
11 Correct 67 ms 660 KB Output is correct
12 Correct 72 ms 800 KB Output is correct
13 Correct 66 ms 672 KB Output is correct
14 Correct 65 ms 688 KB Output is correct
15 Correct 65 ms 672 KB Output is correct
16 Correct 67 ms 596 KB Output is correct
17 Correct 65 ms 676 KB Output is correct
18 Correct 85 ms 688 KB Output is correct
19 Runtime error 6 ms 1752 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 468 KB Output is correct
2 Correct 19 ms 696 KB Output is correct
3 Correct 85 ms 828 KB Output is correct
4 Correct 80 ms 724 KB Output is correct
5 Correct 79 ms 708 KB Output is correct
6 Correct 64 ms 816 KB Output is correct
7 Correct 65 ms 684 KB Output is correct
8 Correct 73 ms 708 KB Output is correct
9 Correct 78 ms 676 KB Output is correct
10 Correct 71 ms 680 KB Output is correct
11 Correct 67 ms 660 KB Output is correct
12 Correct 72 ms 800 KB Output is correct
13 Correct 66 ms 672 KB Output is correct
14 Correct 65 ms 688 KB Output is correct
15 Correct 65 ms 672 KB Output is correct
16 Correct 67 ms 596 KB Output is correct
17 Correct 65 ms 676 KB Output is correct
18 Correct 85 ms 688 KB Output is correct
19 Runtime error 6 ms 1752 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -