# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
471626 | 2021-09-10T04:34:36 Z | ToroTN | Pilot (NOI19_pilot) | C++14 | 874 ms | 79632 KB |
#include<bits/stdc++.h> using namespace std; int n,m,a,chk[1000005],p[1000005],node,fuck; long long cnt=0,ans[1000005],l,r; vector<int> v[1000005]; int f(int a) { if(p[a]==a) { return a; } return p[a]=f(p[a]); } void un(int b,int c) { chk[f(c)]+=chk[f(b)]; p[f(b)]=f(c); } int main() { scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { scanf("%d",&a); v[a].push_back(i); chk[i]=1; } for(int i=1;i<=1000000;i++) { for(int j=0;j<v[i].size();j++) { node=v[i][j]; chk[node]=1; p[node]=node; l=(long long)(chk[f(node-1)]); r=(long long)(chk[f(node+1)]); if(l==0&&r==0) { cnt+=1; }else if(l==0) { cnt+=r+(long long)1; }else if(r==0) { cnt+=l+(long long)1; }else { cnt+=(l+(long long)1)*(r+(long long)1); } //printf("%lld\n",cnt); if(p[node-1]!=0) { un(node-1,node); } if(p[node+1]!=0) { un(node+1,node); } /*for(int k=1;k<=n;k++) { printf("%d ",chk[f(k)]); } printf("\n\n");*/ } ans[i]=cnt; } while(m--) { scanf("%d",&fuck); printf("%lld\n",ans[fuck]); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 31564 KB | Output is correct |
2 | Correct | 23 ms | 31520 KB | Output is correct |
3 | Correct | 24 ms | 31620 KB | Output is correct |
4 | Correct | 22 ms | 31596 KB | Output is correct |
5 | Correct | 21 ms | 31608 KB | Output is correct |
6 | Correct | 22 ms | 31636 KB | Output is correct |
7 | Correct | 21 ms | 31608 KB | Output is correct |
8 | Correct | 22 ms | 31628 KB | Output is correct |
9 | Correct | 22 ms | 31576 KB | Output is correct |
10 | Correct | 22 ms | 31604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 31564 KB | Output is correct |
2 | Correct | 23 ms | 31520 KB | Output is correct |
3 | Correct | 24 ms | 31620 KB | Output is correct |
4 | Correct | 22 ms | 31596 KB | Output is correct |
5 | Correct | 21 ms | 31608 KB | Output is correct |
6 | Correct | 22 ms | 31636 KB | Output is correct |
7 | Correct | 21 ms | 31608 KB | Output is correct |
8 | Correct | 22 ms | 31628 KB | Output is correct |
9 | Correct | 22 ms | 31576 KB | Output is correct |
10 | Correct | 22 ms | 31604 KB | Output is correct |
11 | Correct | 22 ms | 31504 KB | Output is correct |
12 | Correct | 21 ms | 31608 KB | Output is correct |
13 | Correct | 21 ms | 31564 KB | Output is correct |
14 | Correct | 21 ms | 31576 KB | Output is correct |
15 | Correct | 22 ms | 31568 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 31564 KB | Output is correct |
2 | Correct | 23 ms | 31520 KB | Output is correct |
3 | Correct | 24 ms | 31620 KB | Output is correct |
4 | Correct | 22 ms | 31596 KB | Output is correct |
5 | Correct | 21 ms | 31608 KB | Output is correct |
6 | Correct | 22 ms | 31636 KB | Output is correct |
7 | Correct | 21 ms | 31608 KB | Output is correct |
8 | Correct | 22 ms | 31628 KB | Output is correct |
9 | Correct | 22 ms | 31576 KB | Output is correct |
10 | Correct | 22 ms | 31604 KB | Output is correct |
11 | Correct | 22 ms | 31504 KB | Output is correct |
12 | Correct | 21 ms | 31608 KB | Output is correct |
13 | Correct | 21 ms | 31564 KB | Output is correct |
14 | Correct | 21 ms | 31576 KB | Output is correct |
15 | Correct | 22 ms | 31568 KB | Output is correct |
16 | Correct | 21 ms | 31604 KB | Output is correct |
17 | Correct | 21 ms | 31564 KB | Output is correct |
18 | Correct | 23 ms | 31588 KB | Output is correct |
19 | Correct | 21 ms | 31560 KB | Output is correct |
20 | Correct | 21 ms | 31528 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 31564 KB | Output is correct |
2 | Correct | 23 ms | 31520 KB | Output is correct |
3 | Correct | 24 ms | 31620 KB | Output is correct |
4 | Correct | 22 ms | 31596 KB | Output is correct |
5 | Correct | 21 ms | 31608 KB | Output is correct |
6 | Correct | 22 ms | 31636 KB | Output is correct |
7 | Correct | 21 ms | 31608 KB | Output is correct |
8 | Correct | 22 ms | 31628 KB | Output is correct |
9 | Correct | 22 ms | 31576 KB | Output is correct |
10 | Correct | 22 ms | 31604 KB | Output is correct |
11 | Correct | 22 ms | 31504 KB | Output is correct |
12 | Correct | 21 ms | 31608 KB | Output is correct |
13 | Correct | 21 ms | 31564 KB | Output is correct |
14 | Correct | 21 ms | 31576 KB | Output is correct |
15 | Correct | 22 ms | 31568 KB | Output is correct |
16 | Correct | 21 ms | 31604 KB | Output is correct |
17 | Correct | 21 ms | 31564 KB | Output is correct |
18 | Correct | 23 ms | 31588 KB | Output is correct |
19 | Correct | 21 ms | 31560 KB | Output is correct |
20 | Correct | 21 ms | 31528 KB | Output is correct |
21 | Correct | 22 ms | 31668 KB | Output is correct |
22 | Correct | 22 ms | 31616 KB | Output is correct |
23 | Correct | 22 ms | 31588 KB | Output is correct |
24 | Correct | 22 ms | 31688 KB | Output is correct |
25 | Correct | 23 ms | 31696 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 53 ms | 34736 KB | Output is correct |
2 | Correct | 74 ms | 35864 KB | Output is correct |
3 | Correct | 60 ms | 34644 KB | Output is correct |
4 | Correct | 65 ms | 35592 KB | Output is correct |
5 | Correct | 49 ms | 34672 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 72 ms | 37276 KB | Output is correct |
2 | Correct | 78 ms | 37296 KB | Output is correct |
3 | Correct | 70 ms | 37180 KB | Output is correct |
4 | Correct | 74 ms | 37476 KB | Output is correct |
5 | Correct | 72 ms | 37192 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 77 ms | 37456 KB | Output is correct |
2 | Correct | 83 ms | 37368 KB | Output is correct |
3 | Correct | 84 ms | 37364 KB | Output is correct |
4 | Correct | 77 ms | 37612 KB | Output is correct |
5 | Correct | 83 ms | 37572 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 31564 KB | Output is correct |
2 | Correct | 23 ms | 31520 KB | Output is correct |
3 | Correct | 24 ms | 31620 KB | Output is correct |
4 | Correct | 22 ms | 31596 KB | Output is correct |
5 | Correct | 21 ms | 31608 KB | Output is correct |
6 | Correct | 22 ms | 31636 KB | Output is correct |
7 | Correct | 21 ms | 31608 KB | Output is correct |
8 | Correct | 22 ms | 31628 KB | Output is correct |
9 | Correct | 22 ms | 31576 KB | Output is correct |
10 | Correct | 22 ms | 31604 KB | Output is correct |
11 | Correct | 53 ms | 34736 KB | Output is correct |
12 | Correct | 74 ms | 35864 KB | Output is correct |
13 | Correct | 60 ms | 34644 KB | Output is correct |
14 | Correct | 65 ms | 35592 KB | Output is correct |
15 | Correct | 49 ms | 34672 KB | Output is correct |
16 | Correct | 56 ms | 34684 KB | Output is correct |
17 | Correct | 72 ms | 35916 KB | Output is correct |
18 | Correct | 72 ms | 35908 KB | Output is correct |
19 | Correct | 48 ms | 34624 KB | Output is correct |
20 | Correct | 69 ms | 35808 KB | Output is correct |
21 | Correct | 50 ms | 34632 KB | Output is correct |
22 | Correct | 74 ms | 35672 KB | Output is correct |
23 | Correct | 52 ms | 34884 KB | Output is correct |
24 | Correct | 66 ms | 35608 KB | Output is correct |
25 | Correct | 51 ms | 34772 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 31564 KB | Output is correct |
2 | Correct | 23 ms | 31520 KB | Output is correct |
3 | Correct | 24 ms | 31620 KB | Output is correct |
4 | Correct | 22 ms | 31596 KB | Output is correct |
5 | Correct | 21 ms | 31608 KB | Output is correct |
6 | Correct | 22 ms | 31636 KB | Output is correct |
7 | Correct | 21 ms | 31608 KB | Output is correct |
8 | Correct | 22 ms | 31628 KB | Output is correct |
9 | Correct | 22 ms | 31576 KB | Output is correct |
10 | Correct | 22 ms | 31604 KB | Output is correct |
11 | Correct | 22 ms | 31504 KB | Output is correct |
12 | Correct | 21 ms | 31608 KB | Output is correct |
13 | Correct | 21 ms | 31564 KB | Output is correct |
14 | Correct | 21 ms | 31576 KB | Output is correct |
15 | Correct | 22 ms | 31568 KB | Output is correct |
16 | Correct | 21 ms | 31604 KB | Output is correct |
17 | Correct | 21 ms | 31564 KB | Output is correct |
18 | Correct | 23 ms | 31588 KB | Output is correct |
19 | Correct | 21 ms | 31560 KB | Output is correct |
20 | Correct | 21 ms | 31528 KB | Output is correct |
21 | Correct | 22 ms | 31668 KB | Output is correct |
22 | Correct | 22 ms | 31616 KB | Output is correct |
23 | Correct | 22 ms | 31588 KB | Output is correct |
24 | Correct | 22 ms | 31688 KB | Output is correct |
25 | Correct | 23 ms | 31696 KB | Output is correct |
26 | Correct | 53 ms | 34736 KB | Output is correct |
27 | Correct | 74 ms | 35864 KB | Output is correct |
28 | Correct | 60 ms | 34644 KB | Output is correct |
29 | Correct | 65 ms | 35592 KB | Output is correct |
30 | Correct | 49 ms | 34672 KB | Output is correct |
31 | Correct | 72 ms | 37276 KB | Output is correct |
32 | Correct | 78 ms | 37296 KB | Output is correct |
33 | Correct | 70 ms | 37180 KB | Output is correct |
34 | Correct | 74 ms | 37476 KB | Output is correct |
35 | Correct | 72 ms | 37192 KB | Output is correct |
36 | Correct | 77 ms | 37456 KB | Output is correct |
37 | Correct | 83 ms | 37368 KB | Output is correct |
38 | Correct | 84 ms | 37364 KB | Output is correct |
39 | Correct | 77 ms | 37612 KB | Output is correct |
40 | Correct | 83 ms | 37572 KB | Output is correct |
41 | Correct | 56 ms | 34684 KB | Output is correct |
42 | Correct | 72 ms | 35916 KB | Output is correct |
43 | Correct | 72 ms | 35908 KB | Output is correct |
44 | Correct | 48 ms | 34624 KB | Output is correct |
45 | Correct | 69 ms | 35808 KB | Output is correct |
46 | Correct | 50 ms | 34632 KB | Output is correct |
47 | Correct | 74 ms | 35672 KB | Output is correct |
48 | Correct | 52 ms | 34884 KB | Output is correct |
49 | Correct | 66 ms | 35608 KB | Output is correct |
50 | Correct | 51 ms | 34772 KB | Output is correct |
51 | Correct | 82 ms | 36164 KB | Output is correct |
52 | Correct | 114 ms | 37056 KB | Output is correct |
53 | Correct | 87 ms | 36296 KB | Output is correct |
54 | Correct | 101 ms | 37020 KB | Output is correct |
55 | Correct | 82 ms | 36148 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 31564 KB | Output is correct |
2 | Correct | 23 ms | 31520 KB | Output is correct |
3 | Correct | 24 ms | 31620 KB | Output is correct |
4 | Correct | 22 ms | 31596 KB | Output is correct |
5 | Correct | 21 ms | 31608 KB | Output is correct |
6 | Correct | 22 ms | 31636 KB | Output is correct |
7 | Correct | 21 ms | 31608 KB | Output is correct |
8 | Correct | 22 ms | 31628 KB | Output is correct |
9 | Correct | 22 ms | 31576 KB | Output is correct |
10 | Correct | 22 ms | 31604 KB | Output is correct |
11 | Correct | 22 ms | 31504 KB | Output is correct |
12 | Correct | 21 ms | 31608 KB | Output is correct |
13 | Correct | 21 ms | 31564 KB | Output is correct |
14 | Correct | 21 ms | 31576 KB | Output is correct |
15 | Correct | 22 ms | 31568 KB | Output is correct |
16 | Correct | 21 ms | 31604 KB | Output is correct |
17 | Correct | 21 ms | 31564 KB | Output is correct |
18 | Correct | 23 ms | 31588 KB | Output is correct |
19 | Correct | 21 ms | 31560 KB | Output is correct |
20 | Correct | 21 ms | 31528 KB | Output is correct |
21 | Correct | 22 ms | 31668 KB | Output is correct |
22 | Correct | 22 ms | 31616 KB | Output is correct |
23 | Correct | 22 ms | 31588 KB | Output is correct |
24 | Correct | 22 ms | 31688 KB | Output is correct |
25 | Correct | 23 ms | 31696 KB | Output is correct |
26 | Correct | 53 ms | 34736 KB | Output is correct |
27 | Correct | 74 ms | 35864 KB | Output is correct |
28 | Correct | 60 ms | 34644 KB | Output is correct |
29 | Correct | 65 ms | 35592 KB | Output is correct |
30 | Correct | 49 ms | 34672 KB | Output is correct |
31 | Correct | 72 ms | 37276 KB | Output is correct |
32 | Correct | 78 ms | 37296 KB | Output is correct |
33 | Correct | 70 ms | 37180 KB | Output is correct |
34 | Correct | 74 ms | 37476 KB | Output is correct |
35 | Correct | 72 ms | 37192 KB | Output is correct |
36 | Correct | 77 ms | 37456 KB | Output is correct |
37 | Correct | 83 ms | 37368 KB | Output is correct |
38 | Correct | 84 ms | 37364 KB | Output is correct |
39 | Correct | 77 ms | 37612 KB | Output is correct |
40 | Correct | 83 ms | 37572 KB | Output is correct |
41 | Correct | 56 ms | 34684 KB | Output is correct |
42 | Correct | 72 ms | 35916 KB | Output is correct |
43 | Correct | 72 ms | 35908 KB | Output is correct |
44 | Correct | 48 ms | 34624 KB | Output is correct |
45 | Correct | 69 ms | 35808 KB | Output is correct |
46 | Correct | 50 ms | 34632 KB | Output is correct |
47 | Correct | 74 ms | 35672 KB | Output is correct |
48 | Correct | 52 ms | 34884 KB | Output is correct |
49 | Correct | 66 ms | 35608 KB | Output is correct |
50 | Correct | 51 ms | 34772 KB | Output is correct |
51 | Correct | 82 ms | 36164 KB | Output is correct |
52 | Correct | 114 ms | 37056 KB | Output is correct |
53 | Correct | 87 ms | 36296 KB | Output is correct |
54 | Correct | 101 ms | 37020 KB | Output is correct |
55 | Correct | 82 ms | 36148 KB | Output is correct |
56 | Correct | 855 ms | 78116 KB | Output is correct |
57 | Correct | 874 ms | 79120 KB | Output is correct |
58 | Correct | 849 ms | 75748 KB | Output is correct |
59 | Correct | 834 ms | 77532 KB | Output is correct |
60 | Correct | 872 ms | 79632 KB | Output is correct |