# Codeforces Good Bye 2020 A-D

Time：2021-7-6

A – Bovine Dilemma

Solution: think that the problem said is a triangle, and there is a certain point (0,1), so here only need to find two points can form a triangle, and these two points are on the X axis, so you can know (0,1) to X axis is high, X axis two points only difference is the bottom. So we just need to know how many different values there are at the bottom.

Make a difference between each point and the previous point, and use a marker array B [x] to query whether the difference X has appeared (if it has not appeared, it is 0). If it has not appeared, B [x] + +; On the contrary, sum + +.

``````1 #include
2 using namespace std;
3 int main()
4 {
5     int t,n,a,b,sum,x;
6     scanf("%d",&t);
7     while(t--)
8     {
9         memset(b,0,sizeof(b));
10         sum=0;
11         scanf("%d",&n);
12         for(int d=1;d<=n;d++)
13         {
14             scanf("%d",&a[d]);
15             for(int i=1;i``````

B – Last minute enhancements

How to solve the problem: this problem is to find how many different numbers, and the given data is incremental, so as long as the input number x, query whether X has appeared (in the tag array B + +), if not (that is, B [x] = 0), that x is a new number, sum + +, mark X, B [x] + +; If it has, query whether x + 1 has appeared. If it has not, it means that x + 1 is a new number, sum + +. Mark X + 1, B [x + 1] +.

``````1 #include
2 using namespace std;
3 int b;
4 int main()
5 {
6     int t,n,x,sum;
7     scanf("%d",&t);
8     while(t--)
9     {
10         memset(b,0,sizeof(b));
11         sum=0;
12         scanf("%d",&n);
13         for(int d=1;d<=n;d++)
14         {
15             scanf("%d",&x);
16             if(b[x]==0)
17             {
18                 b[x]++;
19                 sum++;
20             }
21             else
22             {
23                 b[x+1]++;
24                 if(b[x+1]==1)
25                     sum++;
26             }
27         }
28         printf("%d\n",sum);
29     }
30     return 0;
31 }``````

C – Canine poetry

Solution: this problem is very simple, just need to query each character whether it is the same as the character in front of it or the character in front of it. If it is the same, change the character to any character outside the letter, and add up the same every time.

``````1 #include
2 using namespace std;
3 char a;
4 int main()
5 {
6     int n,sum;
7     scanf("%d",&n);
8     while(n--)
9     {
10         sum=0;
11         scanf("%s",a);
12         for(int d=1;a[d]!='1 #include
2 using namespace std;
3 char a;
4 int main()
5 {
6     int n,sum;
7     scanf("%d",&n);
8     while(n--)
9     {
10         sum=0;
11         scanf("%s",a);
12         for(int d=1;a[d]!='\0';d++)
13         {
14             if(a[d]==a[d-1])
15             {
16                 a[d]='!';
17                 sum++;
18             }
19             else if(a[d]==a[d-2]&&d>1)
20             {
21                 a[d]='!';
22                 sum++;
23             }
24         }
25         printf("%d\n",sum);
26     }
27     return 0;
28 }';d++)
13         {
14             if(a[d]==a[d-1])
15             {
16                 a[d]='!';
17                 sum++;
18             }
19             else if(a[d]==a[d-2]&&d>1)
20             {
21                 a[d]='!';
22                 sum++;
23             }
24         }
25         printf("%d\n",sum);
26     }
27     return 0;
28 }``````

D – 13th Labour of Heracles

Solution: if you don’t change a path, you will add an endpoint once more (this endpoint can’t be a node, that is, there is no other node connected to it except the other endpoint this time), so you only need to query the endpoint that establishes the path every time (B [x] is greater than 0). If it doesn’t appear (= 0), you don’t care about it; If it appears (> 0), save it (C [Z] = a [x], Z + +). When sorting the C array from large to small (required by the question), output the sum of N numbers, and then output the sum after adding each C [D].

``````1 #include
2 using namespace std;
3 int a,b,c;
4 long long sum;
5 bool cmp(int x,int y)
6 {
7     return x>y;
8 }
9 int main()
10 {
11     int t,n,x,y,z;
12     scanf("%d",&t);
13     while(t--)
14     {
15         memset(b,0,sizeof(b));
16         memset(c,0,sizeof(c));
17         sum=0;
18         z=1;
19         scanf("%d",&n);
20         for(int d=1;d<=n;d++)
21         {
22             scanf("%d",&a[d]);
23             sum+=a[d];
24         }
25         for(int d=1;d1)
31             {
32                 c[z]=a[x];
33                 z++;
34             }
35             if(b[y]>1)
36             {
37                 c[z]=a[y];
38                 z++;
39             }
40         }
41         sort(c+1,c+z,cmp);
42         z--;
43         printf("%lld ",sum);
44         for(int d=1;d<=z;d++)
45         {
46             sum+=c[d];
47             printf("%lld ",sum);
48         }
49         printf("\n");
50     }
51     return 0;
52 }``````

## How to implement HTAP database? Analysis of column storage engine in Yunxi database

Reading guide The HTAP database integrating TP and AP is becoming the development trend of the industry. However, due to the complexity of TP and AP systems in large-scale data scenarios, it is not easy to integrate the functions of the two scenarios in a database system. The HTAP Yunxi database launched by Inspur adopts […]