2020/7/30 Getting better

game process

Start

On the fourth day of the training camp, the team competition started at 12:00 noon. At the beginning, I didn’t know which question to do first. After looking at the ranking, someone handed in question C (but it was wrong), so we started to study question C. At first glance, it was a string question, but it was actually a brain-moving question. (Thinking) question, switch to question A, question A is relatively simple, Lao Kong has an idea and directly code it out, we see no problem and let him hand it in - overturned, after careful inspection, I found Lao Kong left In one case, I changed it and submitted it again (and WA again).

Accident

At this time, Lao Yan was inspired by the third question, he came up with the code directly, and told us about his ideas. We tested some examples without any problems, and submitted them directly (unexpectedly, it was WA again), and this Several times WA is not a normal WA but a wrong answer at test1, we tried again, still the same problem.

solve

At this time, I felt that there might not be a problem with our thinking, but other problems. Just when we were about to do other problems, Lao Kong found the problem (more than half an hour), and it turned out that we still need to operate the file , using freopen
{ function name: freopen function, re-specify to another file in the specified mode. Modes are used to specify how new files are accessed. Header file: stdio.h } With the addition of freopen, these two questions were quickly solved.




Enter state

For the next question E, Lao Yan directly found the idea. Lao Yan and I began to study how to write the code. Lao Kong tried out the code of this question while humming a song. I tested a few tricky examples. , All passed, direct hand in, once AC is happy. The following two questions are not too difficult. The common problem of the three of us is that we do not understand the meaning of the questions after reading the questions several times. Later, we started to study the B question, and once AC, there were a total of five AC questions, which was one question better than the last time. I feel that our small team still has a lot of room for improvement.

topics learned

Question B

insert image description here
This question is a creative question, the answer is relatively open, just meet the conditions, there are many ways to write
AC code

#include<bits/stdc++.h>
using namespace std;
int main() {
    
    
    int b, w;
    char s[2] = {
    
    '.', '@'};
    // freopen("black.in","r",stdin);
    // freopen("black.out","w",stdout);
    scanf("%d%d", &b, &w);
    if (b > w) {
    
    
        swap(b, w);
        swap(s[0], s[1]);
    }
    printf("%d %d\n", 2 * w, 3);//3可以改为任意一个比2大的数
    for (int i = 0; i < (w - b); i++)
    {
    
    
        printf("%c%c%c\n%c%c%c\n", s[1], s[1], s[1], s[1], s[0], s[1]);//只要注意不让s[0]隔断s[1]就行
    }
    for (int i = 0; i < b; i++)
    {
    
    
        printf("%c%c%c\n%c%c%c\n", s[1], s[1], s[1], s[0], s[0], s[0]);
    }
    return 0;
}

Question C

insert image description here
This question mainly depends on the idea. At first glance, it looks like a string question, but it is actually more like a regular question. The rule is: go to the next string to find the number of the same letters in the previous string, and it will repeat if there are n. n times so subtract n times for every one.
AC code

#include <bits/stdc++.h>
using namespace std;
int main()
{
    
    
    //freopen("concatenation.in", "r", stdin);
    //freopen("concatenation.out", "w", stdout);
    int sum[210];
    char s1[100010], s2[100010];
    scanf("%s", s1);
    scanf("%s", s2);
    long long int n = strlen(s1), m = strlen(s2);
    int i;
    memset(sum, 0, sizeof(sum));
    for (i = 1; i < n; i++)
    {
    
    
        sum[s1[i]]++;
    }
    long long int counts = n * m;
    for (i = 0; i < m - 1; i++)
    {
    
    
        counts = counts - sum[s2[i]];
    }
    printf("%lld", counts);
    return 0;
}

L question

insert image description here
The meaning of the question: Given a matrix with a maximum size of 100*100, find out the number of directions of the win of each grid. The direction of the win of each grid may be 0-4. You can first set the change of coordinates when walking. Then directly solve the problem violently (the data is not big, just calculate it and add it up)
AC code

#include <stdio.h>
#include <stdlib.h>
int ax[4] = {
    
     0,0,-1,1 };
int ay[4] = {
    
     1,-1,0,0 };
int main() {
    
    
    //freopen("lucky.in", "r", stdin);
    //freopen("lucky.out", "w", stdout);
	int n, m;
	int a[110][110];
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++)
	{
    
    
		for (int j = 1; j <= m; j++)
			scanf("%d", &a[i][j]);
	}
	int sum = 0;
	for (int i = 1; i <= n; i++)
	{
    
    
		for (int j = 1; j <= m; j++)
		{
    
    
			for (int k = 0; k < 4; k++)
			{
    
    
				int x = i + ax[k];
				int y = j + ay[k];
				int  f = 1;
				while (x >= 1 && x <= n&&y >= 1 && y <= m )
				{
    
    
					if (a[x][y] >= a[i][j])
					{
    
    
						f = 0;
						break;
					}
					x =x+ ax[k];
					y =y+ ay[k];
					
				}
				sum = sum + f;
			}
		}
	}
	printf("%d\n", sum);
    return 0;
}

Reflection after the game

In this competition, we all got to know each other a lot, and gradually developed a tacit understanding. We still need to improve our English skills, otherwise reading and understanding the questions will be a problem (inexplicable rhyme). We still have to train harder and learn more algorithms and mathematical foundations. The questions in the real competition must be much more difficult than ordinary training. It is better to be humble than coincidence, sdutACM and acmer will get better and better. come on! ! ! Ollie

Guess you like

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