제출 #1329589

#제출 시각아이디문제언어결과실행 시간메모리
1329589SinaPourkashaniBubble Sort 2 (JOI18_bubblesort2)C++20
0 / 100
1291 ms888 KiB
#include "bubblesort2.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector <pair<ll, ll>> vp;
typedef pair<ll, ll> pll;
typedef map <ll, ll> mll;
typedef set <ll> sll;
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define print(x) for (auto i : x) cout << i << ' '; cout << '\n';
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

const ll maxn = 3e5+5;
const ll mod = 1e9+7;
const ll inf = 2e18;

ll pw(ll a, ll b, ll M = mod) {ll ans = 1; for (; b; a = ((a * a) % M), b >>= 1) if (b & 1) ans = (ans * a) % M; return ans;}

ll inv[maxn];

vector<int> countScans(vector<int> a,vector<int> x,vector<int> v){
	ll q = x.size();
	ll n = a.size();
	vector<int> ans(q);
	
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < i; j++) {
			if (a[i] < a[j]) inv[i]++;
		}
	}

	for (ll j = 0; j < q; j++) {
		for (ll k = x[j]+1; k < n; k++) {
			if (a[k] < a[x[j]]) {
				inv[k]--;
			}
		}

		a[x[j]] = v[j];

		for (ll k = x[j]+1; k < n; k++) {
			if (a[k] < v[j]) {
				inv[k]++;
			}
		}

		for (ll k = 0; k < x[j]; k++) {
			if (a[k] > v[j]) {
				inv[x[j]]++;
			}
		}

		ll mx = 0;
		for (ll i = 0; i < n; i++) {
			mx = max(mx, inv[i]);
		}

		ans[j] = mx;
	}

	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...