QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#446756#6386. Dollsvakop0 4ms20920kbC++141.1kb2024-06-17 15:52:302024-06-17 15:52:31

Judging History

你现在查看的是最新测评结果

  • [2024-06-17 15:52:31]
  • 评测
  • 测评结果:0
  • 用时:4ms
  • 内存:20920kb
  • [2024-06-17 15:52:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

const int mxN = 1e6 + 5;
ll n,a[mxN];
bool vis[mxN];
struct ds{
	vector<ll> par,siz;
	
	void init(){
		par.resize(mxN);
		siz.assign(mxN, 1LL);
		for(int i = 1; i < mxN; i++) par[i] = i;
	}
	
	ll find(ll a){
		if(par[a] == a) return a;
		par[a] = find(par[a]);
		return par[a];
	}
	
	void merge(ll a, ll b){
		ll p1 = find(a), p2 = find(b);
		if(p1 < p2) swap(p1, p2);
		par[p2] = p1;
		siz[p1] += siz[p2]; 
	}
	
	ll sz(ll a){
		return siz[par[a]];
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);	
	cin >> n;
	ll ans = 0;
	ds s;
	s.init();
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(vis[a[i]]){
			cout << ans << '\n';
			continue;
		}
		vis[a[i]] = true;
		if(vis[a[i] - 1]){
			ans -= (s.sz(a[i] - 1) + 1) / 2;
			s.merge(a[i] - 1, a[i]);
		}
		if(vis[a[i] + 1]){
			ans -= (s.sz(a[i] + 1) + 1) / 2;
			s.merge(a[i] + 1, a[i]);
		}
		ans += (s.sz(a[i]) + 1) / 2;
		cout << ans << '\n';
	}
}    

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 20920kb

input:

190
57 94 24 27 110 44 72 82 55 7 9 43 22 86 95 84 125 16 75 28 46 10 14 131 112 132 33 53 103 139 118 126 137 13 140 77 25 23 47 116 68 150 81 97 165 58 88 63 42 89 123 11 113 83 124 130 80 35 143 155 153 48 8 136 104 101 90 37 21 99 142 34 64 115 109 26 92 144 61 51 114 49 148 96 60 30 54 134 141 ...

output:

1
2
3
4
5
6
7
8
9
10
11
11
12
13
13
14
15
16
17
17
18
18
19
20
21
21
22
23
24
25
26
26
27
27
27
28
28
28
28
29
30
31
31
32
33
33
34
35
36
36
37
38
38
38
38
39
41
42
43
44
45
46
47
47
47
48
49
50
52
53
53
53
53
53
53
53
54
55
56
57
58
58
59
59
59
60
60
61
62
63
63
64
64
65
66
68
69
69
70
71
74
74
74
...

result:

wrong answer 1st lines differ - expected: '1 2 3 4 5 6 7 8 9 10 11 11 12 ...7 77 77 77 77 77 77 77 77 77 77', found: '1'

Subtask #2:

score: 0
Wrong Answer

Test #22:

score: 0
Wrong Answer
time: 4ms
memory: 20804kb

input:

3922
1195 63679 1195 96797 63679 60311 456263 228361 96797 270167 60311 169529 60311 60311 456263 270167 169529 375829 169529 169529 270167 375829 60311 228361 1195 375829 96797 375829 375829 96797 375829 169529 456263 375829 1195 375829 456263 96797 169529 228361 63679 270167 212365 456263 270167 9...

output:

1
2
2
3
3
4
5
6
6
7
7
8
8
8
8
8
8
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
...

result:

wrong answer 1st lines differ - expected: '1 2 2 3 3 4 5 6 6 7 7 8 8 8 8 ...0 10 10 10 10 10 10 10 10 10 10', found: '1'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%