2018 Blue Bridge Cup Summary

Freshman year, my first Blue Bridge Cup, I didn't fall asleep until about 2 o'clock in the evening, got up at 5:30 in the morning, and then I sat in the car for another hour due to motion sickness, and I was in poor condition.


1. Title: Days

January 1, 2000, was the first day of that year.

So, on May 4, 2000, what day was it in that year?

Analysis: I missed a day, and I missed a day after I did it twice!

           For the first time, when I opened the windows calendar for pure numbers, I actually clicked on the 2010, and I was blind.

           The second time, my sixth sense told me that something was wrong, and then I used excel to calculate it again. I actually used the latter to subtract the former. I was mentally retarded. .


2. Title:


The glyphs of plain-coded Chinese characters exist in the font library. Even today, the 16-dot font library is still widely used.
The 16-dot font library regards each Chinese character as 16x16 pixel information. And record this information in bytes.


One byte can store 8 bits of information, and 32 bytes can store the glyph of a Chinese character.
Convert each byte to binary representation, 1 for ink, 0 for background color. 2 bytes per line, a
total of 16 lines, the layout is:


    1st byte, 2nd byte
    , 3rd byte, 4th byte
    ....
    31st byte, 32nd byte


This question is for You are a piece of information composed of multiple Chinese characters, each Chinese character is represented by 32 bytes, and the value of the byte as a signed integer is given here.


The title's requirements are hidden in this information. Your task is to restore the glyphs of these Chinese characters, find out the requirements of the questions, and fill in the answers according to the requirements.


This message is (10 Chinese characters in total):
4 0 4 0 4 0 4 32 -1 -16 4 32 4 32 4 32 4 32 4 32 8 32 8 32 16 34 16 34 32 30 -64 0 
16 64 16 64 34 68 127 126 66 -124 67 4 66 4 66 -124 126 100 66 36 66 4 66 4 66 4 126 4 66 40 0 ​​16 
4 0 4 0 4 0 4 32 -1 -16 4 32 4 32 4 32 4 32 4 32 8 32 8 32 16 34 16 34 32 30 -64 0 
0 -128 64 -128 48 -128 17 8 1 -4 2 8 8 80 16 64 32 64 -32 64 32 -96 32 -96 33 16 34 8 36 14 40 4 
4 0 3 0 1 0 0 4 -1 -2 4 0 4 16 7 -8 4 16 4 16 4 16 8 16 8 16 16 16 32 -96 64 64 
16 64 20 72 62 -4 73 32 5 16 1 0 63 -8 1 0 -1 -2 0 64 0 80 63 -8 8 64 4 64 1 64 0 -128 
0 16 63 -8 1 0 1 0 1 0 1 4 -1 -2 1 0 1 0 1 0 1 0 1 0 1 0 1 0 5 0 2 0 
2 0 2 0 7 -16 8 32 24 64 37 -128 2 -128 12 -128 113 -4 2 8 12 16 18 32 33 -64 1 0 14 0 112 0 
1 0 1 0 1 0 9 32 9 16 17 12 17 4 33 16 65 16 1 32 1 64 0 -128 1 0 2 0 12 0 112 0 

0 0 0 0 7 -16 24 24 48 12 56 12 0 56 0 -32 0 -64 0 -128 0 0 0 0 1 -128 3 -64 1 -128 0 0 

Analysis: No, I was going to list them one by one, but I found that it took too much time


3. Title:


The 10 lines of data with trailing zeros are as follows, each line has 10 integers, how many zeros are there at the end of their product?


5650 4542 35544739464114 38719073904329 2,758,794,961,135,659 
5,245,743,230,514,434 6704 3594 
9937 1173 6,866,339,747,597,557 3,070,228,714,539,899 1,486,572,231,351,170 
4014 
5,510,512,072,928,809,019 2,049,698,458,243,464,427 6,469,742,734,012,307,683 
5693 7015 6887 7,381,417,243,412,909 7355 5649 2027 
6701 6,645,167,159,782,704 9,926,295,312,538,786,785 2,066,424,748,001,578 
6,652,461,611,136,205 2915 3264 
3966 5291 2,904,128,521,931,428 2,265,873,094,367,074 

689 5510 8243 6114 337 4096 8199 7313 3685 211 


Idea: Find the number of factors of 5 and 2 of each integer, and finally find the smallest of the total number of 2 and 5. I counted 31


4. Title:


The inhabitants of planet x test times are not very good-tempered, but fortunately, the only abnormal behavior when they are angry is to drop their mobile phones.
Major manufacturers have also launched a variety of drop-resistant mobile phones. The Quality Supervision Bureau of Planet X stipulates that the mobile phone must pass the drop test and be assessed a drop resistance index before it is allowed to be listed for circulation.


Planet X has a lot of towering towers that are just right for a drop test. Each floor of the tower is the same height, with a slight difference on Earth, their first floor is not the ground, but is equivalent to our 2nd floor.


If the phone is dropped from the 7th layer without breaking, but the 8th layer is broken, the phone's drop resistance index = 7.
In particular, if the phone is broken when dropped from the first layer, the drop resistance index = 0.
If the nth floor of the top floor of the tower is not broken, then the drop resistance index = n


In order to reduce the number of tests, 3 mobile phones are sampled from each manufacturer to participate in the test.


In one test, the tower height is 1000 layers. If we always adopt the best strategy, how many times does it take to determine the drop resistance index of the mobile phone under the worst luck?


Analysis: My idea is to start with two points, throw once at 500 layers and blow up; throw once at 250 layers and blow up; and then throw from 1 to 249 to the end, a total of 251 times. But this seems to be wrong...


5. Title: Quick Sort. 


The following code can find the kth smallest element from the array a[].




It uses a divide-and-conquer algorithm similar to quicksort, and the expected time complexity is O(N).




Please read the analysis source code carefully and fill in the missing content in the underlined part.


#include <stdio.h>


int quick_select(int a[], int l, int r, int k) {
int p = rand() % (r - l + 1) + l;
int x = a[p];
{int t = a[p]; a[p] = a[r]; a[r] = t;}
int i = l, j = r;
while(i < j) {
while(i < j && a [i] < x) i++;
if(i < j) {
a[j] = a[i];
j--;
}
while(i < j && a[j] > x) j--;
if(i < j) {
a[i] = a[j];
i++;
}
}
a[i] = x;
p = i;
if(i - l + 1 == k) return a[i];
if(i - l + 1 < k) return quick_select( _____________________________ ); //fill in the blank
else return quick_select(a, l, i - 1, k);
}int main(){int a[] = {1, 4, 2, 8, 5, 7, 23, 58, 16, 27, 55, 13, 26, 24, 12};printf("%d\n", quick_select(a, 0, 14, 5));return 0;






}


Idea: I'm not very familiar with fast sorting (after all, I'm only a freshman, I just read it a little when I read the previous questions, and then... I'm really not lazy, there is an omnipotent STL, who has nothing to learn this = = ), filled in blindly, tested a few sets of data and all are correct, but the filling in seems to be different from others


6. Title: Incrementing triples


Given three integer arrays
A = [A1, A2, ... AN], 
B = [B1, B2, ... BN], 
C = [C1, C2, ... CN],
please count how many triples (i, j, k) satisfy:
1. 1 <= i, j, k <= N  
2. Ai < Bj < Ck  


[Input format] 
The first line contains a integer N.
The second row contains N integers A1, A2, ... AN.
The third row contains N integers B1, B2, ... BN.
The fourth line contains N integers C1, C2, ... CN.


For 30% of the data, 1 <= N <= 100  
For 60% of the data, 1 <= N <= 1000 
For 100% of the data, 1 <= N <= 100000 0 <= Ai, Bi, Ci <= 100000 


[Output format]
An integer represents the answer


[Sample input]
3
1 1 1
2 2 2
3 3 3


[Sample output]

27 


Idea: Sort first, then triple loop (I originally wanted to add a second point, I haven’t written it for too long, I’m afraid of making mistakes, and this is not like ACM, and it will get 0 points if it times out, so it should be able to mix points)


7. Spiral

Will not


8. Title: Log Statistics


Xiaoming maintains a programmers forum. Now he has collected a "like" log, which has N lines in total. The format of each line is:


ts id  


indicates that the post with the id number at ts time received a "like".  


Now Xiao Ming wants to count which posts were once "hot posts". If a post has received no less than K likes in any period of length D, Xiao Ming considers the post to be a "hot post".  


Specifically, if there is a certain moment T that satisfies that the post receives no less than K likes within the period of [T, T+D) (note that it is the left-closed and right-open interval), the post was once "hot" post".  


Given the log, please help Xiaoming to count all the post numbers that were "hot posts".  


【Input format】
The first line contains three integers N, D and K.  
The following N lines have one log per line, containing two integers ts and id.  


For 50% of the data, 1 <= K <= N <= 1000  
For 100% of the data, 1 <= K <= N <= 100000 0 <= ts <= 100000 0 <= id <  


= 100000 [Output format]
Output the hot post ids in ascending order. One row per id.  


【Input example】
7 10 2  
0 1  
0 10    
10 10  
10 1  
9 1
100 3  
100 3  


【Output example】
1  

3  


Idea: Using the prefix sum method, violence should be able to mix points


9. Title: Global Warming


You have a photo of NxN pixels in a certain sea area, "." means ocean and "#" means land, as follows:


.......
.##....
.## ....
....##.
..####.
...###.
.......


Among them, a piece of land connected in the four directions of "up, down, left and right" forms an island . For example, there are 2 islands in the picture above.  


Due to rising sea levels caused by global warming, scientists predict that a pixel of the edge of the island will be submerged by sea water in the next few decades. Specifically, if a land pixel is adjacent to an ocean (there are oceans in four adjacent pixels up, down, left, and right), it will be submerged.  


For example, the sea area in the picture above will look like this in the future:


.......
......
.......
.......
#..
.. ....... Please count: According to scientists' predictions, how many islands in the photo will be completely submerged  
. 【Input format】The first line contains an integer N. (1 <= N <= 1000)   The following N rows and N columns represent a sea area photo.  The photo guarantees that the pixels in row 1, column 1, row N, and column N are all oceans.  [Output format] An integer represents the answer. 【Input example】....... .##.... .##....






















....##.
..####.
...###.
.......  


[Example of output]

1  


Ideas: This question is similar to a classic example of DFS, but that question is asking how many islands there are. We can change our thinking, search first, mark all # surrounded by # on all sides, and then use DFS to search, each time we search for an island, sum++, if the island has a marked #, then sum--.


10. Title: Product up


to N integers A1, A2, ... AN are given. Please select the K numbers from which the product is the largest.  


Please find the largest product. Since the product may exceed the integer range, you only need to output the remainder of dividing the product by 1000000009.  


Note that if X<0, we define that the remainder of dividing X by 1000000009 is the remainder of a negative (-X) dividing by 1000000009.
That is: 0-((0-x) % 1000000009)


[Input format]
The first line contains two integers N and K.  
Each of the following N lines contains an integer Ai.  


For 40% of the data, 1 <= K <= N <= 100  
For 60% of the data, 1 <= K <= 1000  
For 100% of the data, 1 <= K <= N <= 100000 -100000 <= Ai <= 100000  


[Output format]
An integer, representing the answer.




【Input example】
5 3 
-100000   
-10000   
2   
100000  
10000  


【Output example】
999100009


Another example:
【Input example】
5 3 
-100000   
-100000   
-2   
-100000  
-100000


【Example of output】

-999999829


Idea: No, I sort it directly and multiply the largest k numbers to mix the scores.



Summary: The correct answer should be 3, 5, depending on the data, 6, 8 should get most of the points, 9 should be all correct, and other questions may be mixed with three or four points (the first question is five points. Nope, mind explodes)


-------------------------------------------------- -------------------------------------------------- ------------------------------Follow-up: Successfully mixed a province one, I don't know if the road expenses will be reimbursed in the finals, if not reimbursed If I don't go, I will go to Beijing to travel for reimbursement, and play the finals by the way.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325583296&siteId=291194637