QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#287943#6386. Dollsacwatle0 0ms7420kbC++141.4kb2023-12-21 12:26:442023-12-21 12:26:45

Judging History

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

  • [2023-12-21 12:26:45]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:7420kb
  • [2023-12-21 12:26:44]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
const int MAX = 5e5;
int n,a[N],dp[N],par[MAX],sz[MAX];
bool f[MAX];

void make_set(int v) {
    par[v] = v;
    sz[v] = 1;
}

int find_set(int v) {
    if (v == par[v]) return v;
    int p = find_set(par[v]);
    par[v] = p;
    return p;
}

void union_sets(int a,int b) {
    a = find_set(a),b = find_set(b);
    if (a == b) return;
    if (sz[a] < sz[b]) swap(a,b);
    sz[a] += sz[b];
    par[b] = a;
}

void solve() {
    int ans = 0;
    for (int i = 0; i <= MAX; i++) make_set(i);
    for (int i = 1; i <= n; i++) {
        if (!f[a[i]]) {
            f[a[i]] = true;
            ans++;
            if (f[a[i] - 1]) {
                ans += (sz[find_set(a[i])] + sz[find_set(a[i] - 1)] + 1) / 2;
                ans -= (sz[find_set(a[i])] + 1) / 2;
                ans -= (sz[find_set(a[i] - 1)] + 1) / 2;
                union_sets(a[i],a[i] - 1);
            }
            if (f[a[i] + 1]) {
                ans += (sz[find_set(a[i])] + sz[find_set(a[i] + 1)] + 1) / 2;
                ans -= (sz[find_set(a[i])] + 1) / 2;
                ans -= (sz[find_set(a[i] + 1)] + 1) / 2;
                union_sets(a[i],a[i] + 1);
            }
        }
        cout << ans << "\n";
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    solve();
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 7324kb

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
40
41
42
43
44
45
45
45
45
46
47
48
49
50
50
50
50
50
50
50
51
52
53
54
55
55
56
56
56
57
57
58
58
58
58
59
59
60
60
60
61
61
62
63
63
63
63
...

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: 0ms
memory: 7420kb

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%