# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
545718 |
2022-04-05T09:15:27 Z |
balbit |
Pilot (NOI19_pilot) |
C++14 |
|
699 ms |
89968 KB |
#include <bits/stdc++.h>
#define int ll
using namespace std;
#define ll long long
#define f first
#define s second
#define pii pair<int, int>
#define MX(a,b) a=max(a,b)
#define MN(a,b) a=min(a,b)
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define REP(i,n) for (int i = 0; i<n; ++i)
#define REP1(i,n) for (int i = 1; i<=n; ++i)
#define pb push_back
#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do( T && x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do( T && x, S && ...y) {cerr<<x<<", "; _do(y...);}
#else
#define bug(...)
#define endl '\n'
#endif // BALBIT
const int maxn = 1e6+5;
int par[maxn];
int sz[maxn];
bool on[maxn];
ll re = 0;
int find(int x) {return x == par[x]?x:par[x] = find(par[x]);}
void mrg(int a, int b) {
a = find(a); b = find(b);
if (a == b) return;
re -= sz[a] * (sz[a]+1) / 2;
re -= sz[b] * (sz[b]+1) / 2;
sz[a] += sz[b];
re += sz[a] * (sz[a]+1) / 2;
par[b] = a;
}
vector<int> yay[maxn];
ll ans[maxn];
signed main(){
ios::sync_with_stdio(0), cin.tie(0);
bug(1,2);
int n,q; cin>>n>>q;
REP(i,n) par[i] = i, sz[i] = 1;
REP(i,n) {
int a; cin>>a; yay[a].pb(i);
}
REP1(i, 1000000) {
for (int x : yay[i]) {
++re;
on[x] = 1;
if (x && on[x-1]) mrg(x, x-1);
if (x!=n-1 && on[x+1]) mrg(x, x+1);
}
ans[i] = re;
}
REP(i,q) {
int x; cin>>x;
cout<<ans[x]<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
31572 KB |
Output is correct |
2 |
Correct |
17 ms |
31628 KB |
Output is correct |
3 |
Correct |
17 ms |
31608 KB |
Output is correct |
4 |
Correct |
17 ms |
31628 KB |
Output is correct |
5 |
Correct |
16 ms |
31572 KB |
Output is correct |
6 |
Correct |
17 ms |
31568 KB |
Output is correct |
7 |
Correct |
18 ms |
31700 KB |
Output is correct |
8 |
Correct |
17 ms |
31568 KB |
Output is correct |
9 |
Correct |
18 ms |
31572 KB |
Output is correct |
10 |
Correct |
17 ms |
31572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
31572 KB |
Output is correct |
2 |
Correct |
17 ms |
31628 KB |
Output is correct |
3 |
Correct |
17 ms |
31608 KB |
Output is correct |
4 |
Correct |
17 ms |
31628 KB |
Output is correct |
5 |
Correct |
16 ms |
31572 KB |
Output is correct |
6 |
Correct |
17 ms |
31568 KB |
Output is correct |
7 |
Correct |
18 ms |
31700 KB |
Output is correct |
8 |
Correct |
17 ms |
31568 KB |
Output is correct |
9 |
Correct |
18 ms |
31572 KB |
Output is correct |
10 |
Correct |
17 ms |
31572 KB |
Output is correct |
11 |
Correct |
16 ms |
31616 KB |
Output is correct |
12 |
Correct |
17 ms |
31572 KB |
Output is correct |
13 |
Correct |
17 ms |
31572 KB |
Output is correct |
14 |
Correct |
17 ms |
31628 KB |
Output is correct |
15 |
Correct |
19 ms |
31628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
31572 KB |
Output is correct |
2 |
Correct |
17 ms |
31628 KB |
Output is correct |
3 |
Correct |
17 ms |
31608 KB |
Output is correct |
4 |
Correct |
17 ms |
31628 KB |
Output is correct |
5 |
Correct |
16 ms |
31572 KB |
Output is correct |
6 |
Correct |
17 ms |
31568 KB |
Output is correct |
7 |
Correct |
18 ms |
31700 KB |
Output is correct |
8 |
Correct |
17 ms |
31568 KB |
Output is correct |
9 |
Correct |
18 ms |
31572 KB |
Output is correct |
10 |
Correct |
17 ms |
31572 KB |
Output is correct |
11 |
Correct |
16 ms |
31616 KB |
Output is correct |
12 |
Correct |
17 ms |
31572 KB |
Output is correct |
13 |
Correct |
17 ms |
31572 KB |
Output is correct |
14 |
Correct |
17 ms |
31628 KB |
Output is correct |
15 |
Correct |
19 ms |
31628 KB |
Output is correct |
16 |
Correct |
19 ms |
31572 KB |
Output is correct |
17 |
Correct |
17 ms |
31572 KB |
Output is correct |
18 |
Correct |
17 ms |
31576 KB |
Output is correct |
19 |
Correct |
18 ms |
31572 KB |
Output is correct |
20 |
Correct |
22 ms |
31624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
31572 KB |
Output is correct |
2 |
Correct |
17 ms |
31628 KB |
Output is correct |
3 |
Correct |
17 ms |
31608 KB |
Output is correct |
4 |
Correct |
17 ms |
31628 KB |
Output is correct |
5 |
Correct |
16 ms |
31572 KB |
Output is correct |
6 |
Correct |
17 ms |
31568 KB |
Output is correct |
7 |
Correct |
18 ms |
31700 KB |
Output is correct |
8 |
Correct |
17 ms |
31568 KB |
Output is correct |
9 |
Correct |
18 ms |
31572 KB |
Output is correct |
10 |
Correct |
17 ms |
31572 KB |
Output is correct |
11 |
Correct |
16 ms |
31616 KB |
Output is correct |
12 |
Correct |
17 ms |
31572 KB |
Output is correct |
13 |
Correct |
17 ms |
31572 KB |
Output is correct |
14 |
Correct |
17 ms |
31628 KB |
Output is correct |
15 |
Correct |
19 ms |
31628 KB |
Output is correct |
16 |
Correct |
19 ms |
31572 KB |
Output is correct |
17 |
Correct |
17 ms |
31572 KB |
Output is correct |
18 |
Correct |
17 ms |
31576 KB |
Output is correct |
19 |
Correct |
18 ms |
31572 KB |
Output is correct |
20 |
Correct |
22 ms |
31624 KB |
Output is correct |
21 |
Correct |
17 ms |
31700 KB |
Output is correct |
22 |
Correct |
18 ms |
31700 KB |
Output is correct |
23 |
Correct |
17 ms |
31668 KB |
Output is correct |
24 |
Correct |
18 ms |
31720 KB |
Output is correct |
25 |
Correct |
19 ms |
31640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
35796 KB |
Output is correct |
2 |
Correct |
61 ms |
36792 KB |
Output is correct |
3 |
Correct |
40 ms |
35660 KB |
Output is correct |
4 |
Correct |
56 ms |
36428 KB |
Output is correct |
5 |
Correct |
38 ms |
35600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
38200 KB |
Output is correct |
2 |
Correct |
56 ms |
38176 KB |
Output is correct |
3 |
Correct |
52 ms |
38048 KB |
Output is correct |
4 |
Correct |
50 ms |
38392 KB |
Output is correct |
5 |
Correct |
51 ms |
38000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
38344 KB |
Output is correct |
2 |
Correct |
54 ms |
38280 KB |
Output is correct |
3 |
Correct |
57 ms |
38140 KB |
Output is correct |
4 |
Correct |
56 ms |
38544 KB |
Output is correct |
5 |
Correct |
71 ms |
38392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
31572 KB |
Output is correct |
2 |
Correct |
17 ms |
31628 KB |
Output is correct |
3 |
Correct |
17 ms |
31608 KB |
Output is correct |
4 |
Correct |
17 ms |
31628 KB |
Output is correct |
5 |
Correct |
16 ms |
31572 KB |
Output is correct |
6 |
Correct |
17 ms |
31568 KB |
Output is correct |
7 |
Correct |
18 ms |
31700 KB |
Output is correct |
8 |
Correct |
17 ms |
31568 KB |
Output is correct |
9 |
Correct |
18 ms |
31572 KB |
Output is correct |
10 |
Correct |
17 ms |
31572 KB |
Output is correct |
11 |
Correct |
49 ms |
35796 KB |
Output is correct |
12 |
Correct |
61 ms |
36792 KB |
Output is correct |
13 |
Correct |
40 ms |
35660 KB |
Output is correct |
14 |
Correct |
56 ms |
36428 KB |
Output is correct |
15 |
Correct |
38 ms |
35600 KB |
Output is correct |
16 |
Correct |
38 ms |
35600 KB |
Output is correct |
17 |
Correct |
52 ms |
36788 KB |
Output is correct |
18 |
Correct |
65 ms |
36912 KB |
Output is correct |
19 |
Correct |
41 ms |
35512 KB |
Output is correct |
20 |
Correct |
54 ms |
36676 KB |
Output is correct |
21 |
Correct |
43 ms |
35580 KB |
Output is correct |
22 |
Correct |
53 ms |
36568 KB |
Output is correct |
23 |
Correct |
44 ms |
35936 KB |
Output is correct |
24 |
Correct |
51 ms |
36480 KB |
Output is correct |
25 |
Correct |
38 ms |
35788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
31572 KB |
Output is correct |
2 |
Correct |
17 ms |
31628 KB |
Output is correct |
3 |
Correct |
17 ms |
31608 KB |
Output is correct |
4 |
Correct |
17 ms |
31628 KB |
Output is correct |
5 |
Correct |
16 ms |
31572 KB |
Output is correct |
6 |
Correct |
17 ms |
31568 KB |
Output is correct |
7 |
Correct |
18 ms |
31700 KB |
Output is correct |
8 |
Correct |
17 ms |
31568 KB |
Output is correct |
9 |
Correct |
18 ms |
31572 KB |
Output is correct |
10 |
Correct |
17 ms |
31572 KB |
Output is correct |
11 |
Correct |
16 ms |
31616 KB |
Output is correct |
12 |
Correct |
17 ms |
31572 KB |
Output is correct |
13 |
Correct |
17 ms |
31572 KB |
Output is correct |
14 |
Correct |
17 ms |
31628 KB |
Output is correct |
15 |
Correct |
19 ms |
31628 KB |
Output is correct |
16 |
Correct |
19 ms |
31572 KB |
Output is correct |
17 |
Correct |
17 ms |
31572 KB |
Output is correct |
18 |
Correct |
17 ms |
31576 KB |
Output is correct |
19 |
Correct |
18 ms |
31572 KB |
Output is correct |
20 |
Correct |
22 ms |
31624 KB |
Output is correct |
21 |
Correct |
17 ms |
31700 KB |
Output is correct |
22 |
Correct |
18 ms |
31700 KB |
Output is correct |
23 |
Correct |
17 ms |
31668 KB |
Output is correct |
24 |
Correct |
18 ms |
31720 KB |
Output is correct |
25 |
Correct |
19 ms |
31640 KB |
Output is correct |
26 |
Correct |
49 ms |
35796 KB |
Output is correct |
27 |
Correct |
61 ms |
36792 KB |
Output is correct |
28 |
Correct |
40 ms |
35660 KB |
Output is correct |
29 |
Correct |
56 ms |
36428 KB |
Output is correct |
30 |
Correct |
38 ms |
35600 KB |
Output is correct |
31 |
Correct |
51 ms |
38200 KB |
Output is correct |
32 |
Correct |
56 ms |
38176 KB |
Output is correct |
33 |
Correct |
52 ms |
38048 KB |
Output is correct |
34 |
Correct |
50 ms |
38392 KB |
Output is correct |
35 |
Correct |
51 ms |
38000 KB |
Output is correct |
36 |
Correct |
55 ms |
38344 KB |
Output is correct |
37 |
Correct |
54 ms |
38280 KB |
Output is correct |
38 |
Correct |
57 ms |
38140 KB |
Output is correct |
39 |
Correct |
56 ms |
38544 KB |
Output is correct |
40 |
Correct |
71 ms |
38392 KB |
Output is correct |
41 |
Correct |
38 ms |
35600 KB |
Output is correct |
42 |
Correct |
52 ms |
36788 KB |
Output is correct |
43 |
Correct |
65 ms |
36912 KB |
Output is correct |
44 |
Correct |
41 ms |
35512 KB |
Output is correct |
45 |
Correct |
54 ms |
36676 KB |
Output is correct |
46 |
Correct |
43 ms |
35580 KB |
Output is correct |
47 |
Correct |
53 ms |
36568 KB |
Output is correct |
48 |
Correct |
44 ms |
35936 KB |
Output is correct |
49 |
Correct |
51 ms |
36480 KB |
Output is correct |
50 |
Correct |
38 ms |
35788 KB |
Output is correct |
51 |
Correct |
69 ms |
37108 KB |
Output is correct |
52 |
Correct |
78 ms |
37892 KB |
Output is correct |
53 |
Correct |
64 ms |
37264 KB |
Output is correct |
54 |
Correct |
77 ms |
37912 KB |
Output is correct |
55 |
Correct |
58 ms |
37220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
31572 KB |
Output is correct |
2 |
Correct |
17 ms |
31628 KB |
Output is correct |
3 |
Correct |
17 ms |
31608 KB |
Output is correct |
4 |
Correct |
17 ms |
31628 KB |
Output is correct |
5 |
Correct |
16 ms |
31572 KB |
Output is correct |
6 |
Correct |
17 ms |
31568 KB |
Output is correct |
7 |
Correct |
18 ms |
31700 KB |
Output is correct |
8 |
Correct |
17 ms |
31568 KB |
Output is correct |
9 |
Correct |
18 ms |
31572 KB |
Output is correct |
10 |
Correct |
17 ms |
31572 KB |
Output is correct |
11 |
Correct |
16 ms |
31616 KB |
Output is correct |
12 |
Correct |
17 ms |
31572 KB |
Output is correct |
13 |
Correct |
17 ms |
31572 KB |
Output is correct |
14 |
Correct |
17 ms |
31628 KB |
Output is correct |
15 |
Correct |
19 ms |
31628 KB |
Output is correct |
16 |
Correct |
19 ms |
31572 KB |
Output is correct |
17 |
Correct |
17 ms |
31572 KB |
Output is correct |
18 |
Correct |
17 ms |
31576 KB |
Output is correct |
19 |
Correct |
18 ms |
31572 KB |
Output is correct |
20 |
Correct |
22 ms |
31624 KB |
Output is correct |
21 |
Correct |
17 ms |
31700 KB |
Output is correct |
22 |
Correct |
18 ms |
31700 KB |
Output is correct |
23 |
Correct |
17 ms |
31668 KB |
Output is correct |
24 |
Correct |
18 ms |
31720 KB |
Output is correct |
25 |
Correct |
19 ms |
31640 KB |
Output is correct |
26 |
Correct |
49 ms |
35796 KB |
Output is correct |
27 |
Correct |
61 ms |
36792 KB |
Output is correct |
28 |
Correct |
40 ms |
35660 KB |
Output is correct |
29 |
Correct |
56 ms |
36428 KB |
Output is correct |
30 |
Correct |
38 ms |
35600 KB |
Output is correct |
31 |
Correct |
51 ms |
38200 KB |
Output is correct |
32 |
Correct |
56 ms |
38176 KB |
Output is correct |
33 |
Correct |
52 ms |
38048 KB |
Output is correct |
34 |
Correct |
50 ms |
38392 KB |
Output is correct |
35 |
Correct |
51 ms |
38000 KB |
Output is correct |
36 |
Correct |
55 ms |
38344 KB |
Output is correct |
37 |
Correct |
54 ms |
38280 KB |
Output is correct |
38 |
Correct |
57 ms |
38140 KB |
Output is correct |
39 |
Correct |
56 ms |
38544 KB |
Output is correct |
40 |
Correct |
71 ms |
38392 KB |
Output is correct |
41 |
Correct |
38 ms |
35600 KB |
Output is correct |
42 |
Correct |
52 ms |
36788 KB |
Output is correct |
43 |
Correct |
65 ms |
36912 KB |
Output is correct |
44 |
Correct |
41 ms |
35512 KB |
Output is correct |
45 |
Correct |
54 ms |
36676 KB |
Output is correct |
46 |
Correct |
43 ms |
35580 KB |
Output is correct |
47 |
Correct |
53 ms |
36568 KB |
Output is correct |
48 |
Correct |
44 ms |
35936 KB |
Output is correct |
49 |
Correct |
51 ms |
36480 KB |
Output is correct |
50 |
Correct |
38 ms |
35788 KB |
Output is correct |
51 |
Correct |
69 ms |
37108 KB |
Output is correct |
52 |
Correct |
78 ms |
37892 KB |
Output is correct |
53 |
Correct |
64 ms |
37264 KB |
Output is correct |
54 |
Correct |
77 ms |
37912 KB |
Output is correct |
55 |
Correct |
58 ms |
37220 KB |
Output is correct |
56 |
Correct |
688 ms |
87648 KB |
Output is correct |
57 |
Correct |
681 ms |
89000 KB |
Output is correct |
58 |
Correct |
627 ms |
85024 KB |
Output is correct |
59 |
Correct |
659 ms |
86800 KB |
Output is correct |
60 |
Correct |
699 ms |
89968 KB |
Output is correct |