Submission #925063

# Submission time Handle Problem Language Result Execution time Memory
925063 2024-02-10T16:03:16 Z ttamx Bubble Sort 2 (JOI18_bubblesort2) C++14
100 / 100
1604 ms 38852 KB
#include "bubblesort2.h"
#include<bits/stdc++.h>

using namespace std;

using pi = pair<int,int>;

struct Segtree{
	int n;
	vector<int> t,lz;
	Segtree(int _n){
		n=_n;
		int s=4<<(31-__builtin_clz(n));
		t.assign(s,0);
		lz.assign(s,0);
	}
	void push(int l,int r,int i){
		t[i]+=lz[i];
		if(l<r){
			lz[i*2]+=lz[i];
			lz[i*2+1]+=lz[i];
		}
		lz[i]=0;
	}
	void update(int l,int r,int i,int x,int y,int v){
		push(l,r,i);
		if(y<l||r<x)return;
		if(x<=l&&r<=y)return lz[i]=v,push(l,r,i);
		int m=(l+r)/2;
		update(l,m,i*2,x,y,v);
		update(m+1,r,i*2+1,x,y,v);
		t[i]=max(t[i*2],t[i*2+1]);
	}
	void update(int x,int y,int v){
		update(0,n-1,1,x,y,v);
	}
};

vector<int> countScans(vector<int> a,vector<int> x,vector<int> v){
	int n=a.size();
	int q=x.size();
	vector<int> ans(q);
	vector<pi> vec;
	for(int i=0;i<n;i++)vec.emplace_back(a[i],i);
	for(int i=0;i<q;i++)vec.emplace_back(v[i],x[i]);
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	for(int i=0;i<n;i++)a[i]=lower_bound(vec.begin(),vec.end(),pi(a[i],i))-vec.begin();
	for(int i=0;i<q;i++)v[i]=lower_bound(vec.begin(),vec.end(),pi(v[i],x[i]))-vec.begin();
	Segtree s(n+q);
	auto upd=[&](int i,int v){
		s.update(a[i],a[i],i*v);
		s.update(a[i]+1,n+q,-v);
	};
	for(int i=0;i<n;i++)upd(i,1);
	for(int i=0;i<q;i++){
		upd(x[i],-1);
		a[x[i]]=v[i];
		upd(x[i],1);
		ans[i]=s.t[1];
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 5 ms 616 KB Output is correct
6 Correct 3 ms 556 KB Output is correct
7 Correct 3 ms 604 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 616 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
13 Correct 4 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 3 ms 604 KB Output is correct
16 Correct 3 ms 620 KB Output is correct
17 Correct 3 ms 604 KB Output is correct
18 Correct 5 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 5 ms 616 KB Output is correct
6 Correct 3 ms 556 KB Output is correct
7 Correct 3 ms 604 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 616 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
13 Correct 4 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 3 ms 604 KB Output is correct
16 Correct 3 ms 620 KB Output is correct
17 Correct 3 ms 604 KB Output is correct
18 Correct 5 ms 620 KB Output is correct
19 Correct 13 ms 860 KB Output is correct
20 Correct 14 ms 860 KB Output is correct
21 Correct 14 ms 1048 KB Output is correct
22 Correct 14 ms 860 KB Output is correct
23 Correct 14 ms 860 KB Output is correct
24 Correct 15 ms 860 KB Output is correct
25 Correct 16 ms 860 KB Output is correct
26 Correct 14 ms 860 KB Output is correct
27 Correct 14 ms 860 KB Output is correct
28 Correct 14 ms 1048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 1504 KB Output is correct
2 Correct 62 ms 2768 KB Output is correct
3 Correct 114 ms 4764 KB Output is correct
4 Correct 109 ms 4548 KB Output is correct
5 Correct 107 ms 4776 KB Output is correct
6 Correct 111 ms 4732 KB Output is correct
7 Correct 108 ms 4768 KB Output is correct
8 Correct 108 ms 4552 KB Output is correct
9 Correct 108 ms 4776 KB Output is correct
10 Correct 101 ms 4552 KB Output is correct
11 Correct 100 ms 4552 KB Output is correct
12 Correct 105 ms 4776 KB Output is correct
13 Correct 99 ms 4556 KB Output is correct
14 Correct 100 ms 4560 KB Output is correct
15 Correct 105 ms 4772 KB Output is correct
16 Correct 98 ms 4780 KB Output is correct
17 Correct 98 ms 4552 KB Output is correct
18 Correct 101 ms 4552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
4 Correct 3 ms 604 KB Output is correct
5 Correct 5 ms 616 KB Output is correct
6 Correct 3 ms 556 KB Output is correct
7 Correct 3 ms 604 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 616 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 3 ms 604 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
13 Correct 4 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 3 ms 604 KB Output is correct
16 Correct 3 ms 620 KB Output is correct
17 Correct 3 ms 604 KB Output is correct
18 Correct 5 ms 620 KB Output is correct
19 Correct 13 ms 860 KB Output is correct
20 Correct 14 ms 860 KB Output is correct
21 Correct 14 ms 1048 KB Output is correct
22 Correct 14 ms 860 KB Output is correct
23 Correct 14 ms 860 KB Output is correct
24 Correct 15 ms 860 KB Output is correct
25 Correct 16 ms 860 KB Output is correct
26 Correct 14 ms 860 KB Output is correct
27 Correct 14 ms 860 KB Output is correct
28 Correct 14 ms 1048 KB Output is correct
29 Correct 22 ms 1504 KB Output is correct
30 Correct 62 ms 2768 KB Output is correct
31 Correct 114 ms 4764 KB Output is correct
32 Correct 109 ms 4548 KB Output is correct
33 Correct 107 ms 4776 KB Output is correct
34 Correct 111 ms 4732 KB Output is correct
35 Correct 108 ms 4768 KB Output is correct
36 Correct 108 ms 4552 KB Output is correct
37 Correct 108 ms 4776 KB Output is correct
38 Correct 101 ms 4552 KB Output is correct
39 Correct 100 ms 4552 KB Output is correct
40 Correct 105 ms 4776 KB Output is correct
41 Correct 99 ms 4556 KB Output is correct
42 Correct 100 ms 4560 KB Output is correct
43 Correct 105 ms 4772 KB Output is correct
44 Correct 98 ms 4780 KB Output is correct
45 Correct 98 ms 4552 KB Output is correct
46 Correct 101 ms 4552 KB Output is correct
47 Correct 364 ms 16824 KB Output is correct
48 Correct 1364 ms 36948 KB Output is correct
49 Correct 1472 ms 38580 KB Output is correct
50 Correct 1510 ms 38588 KB Output is correct
51 Correct 1500 ms 38532 KB Output is correct
52 Correct 1517 ms 38320 KB Output is correct
53 Correct 1604 ms 38488 KB Output is correct
54 Correct 1406 ms 38572 KB Output is correct
55 Correct 1493 ms 38580 KB Output is correct
56 Correct 1514 ms 38524 KB Output is correct
57 Correct 1477 ms 38616 KB Output is correct
58 Correct 1376 ms 38572 KB Output is correct
59 Correct 1348 ms 38576 KB Output is correct
60 Correct 1366 ms 38852 KB Output is correct
61 Correct 1323 ms 38820 KB Output is correct
62 Correct 1378 ms 38524 KB Output is correct
63 Correct 1292 ms 38576 KB Output is correct
64 Correct 1327 ms 38720 KB Output is correct
65 Correct 1287 ms 38708 KB Output is correct
66 Correct 1274 ms 38744 KB Output is correct
67 Correct 1257 ms 38528 KB Output is correct