Precautions for CSP semi-finals

Keywords: C++

right off    \; CSP semi-finals    \; It's time for the exam. Here I summarize some points that should be paid attention to in the examination room:

1, Explosion 0

1. Wrong file name

The competition lasted three and a half hours and had four questions. Each topic has a specific file name (usually in English), and the evaluation system looks for it according to the file name
 Your code. If you even write the file name wrong, then:

cannot find file \color{Cyan}\colorbox{Violet} {file not found} File not found , to yes , you light Glory of burst 0 Yes . So, you burst 0 with honor. So, you burst 0 with honor.

resolvent

(1) I won't repeat the spelling mistakes. Please check your file name;
(2) . for the following cases:

Please do the following (win10 system):

  1. Open this computer;
  2. Select View:
  3. Tick the column "file extension".
    You will find:

    dangerous \color{Balck}\colorbox{Red} {dangerous} Perilous

2. MLE

What is? MLE And? Simply put, it's`Space limit overrun`,namely`Memory Limit Exceeded`. This will cause you to lose a point on this question,
Burst 0.

resolvent:

1. Calculate the space complexity S(n) (highlight!)

The usual memory limit is 125.00MB. It looks big. But arrays take up a lot of space. An array of int type needs 4 byte s, 8 bytes of long type and 1 byte of char type.
For good calculation, I Guys hold 128 M B do by within Save limit system . We use 128MB as the memory limit. We use 128MB as the memory limit.
1 M B = 1024 K B , 1 K B = 1024 B , 1 B = 8 B y t e 1MB=1024KB,1KB=1024B,1B=8Byte 1MB=1024KB,1KB=1024B,1B=8Byte
∴ \therefore ∴ 128 M B = 1 × 2 7 + 10 + 10 − 3 + 1 = 2 25 = 33554432 128MB=1 \times2^{7+10+10-3+1}=2^{25}=33554432 128MB=1×27+10+10−3+1=225=33554432
again open individual flat square : 33554432 ≈ 5792.618 Open another square: \ sqrt{33554432}\thickapprox5792.618 Open another square: 33554432 ​≈5792.618
So, generally open i n t int Array of type int should not exceed 5500 5500 5500. Do not exceed [ 220 ] [ 220 ] [220][220] [220][220].

2. Reduce the use of recursive algorithms (very space!!!)

3. Wrong writing of file reading and writing operation

Read and write should be added to each question. If not. Unfortunately, you blew 0.

resolvent:

1. Be able to read and write files.

#include<bits/stdc++.h>
using namespace std;
int n,m;
int main(){
	//These two actions are file read and write operations.
	freopen("plus.in","r",stdin);
	freopen("plus.out","w",stdout);
	//The specific name shall be subject to the examination.
	cin>>n>>m;
	cout<<n+m;
	return 0;
}

2. Leave a few minutes to check the read and write operation!!!

4.RE

What is RE?That's it“ Runtime Error" ,That is, runtime error. The main reasons are as follows:

1. Write the main function type as void.

stay CSP And later NOIP In the exam, c/c++Main function type must be int,Otherwise, an error will be reported.

2. No return 0

Say the important thing three times: it must be added retrun 0!Must add retrun 0!!Must add retrun 0!!!And:
using namespace std;

3. Namely:

int main(){
	int a[20];
	for(int i=1;i<=20;i++){
		cin>>a[i];
	}
	return 0;
}

The array starts at 0

4. Divide by 0:

while(n>=0){
	cout<<m/n;
	n--;
}

2, Operations that may lose points.

1. Code error.

No, okay

2.TLE.

What is TLE Inside? 
TLE Means `Time Limit Eceeded` . That is: the space limit exceeds the limit. Possible conditions:

1. Too many cycles.

The computer is executing 1 0 8 10^8 Operations within 108 will not time out. However, if:

for(int i=1;i<=1000;i++){
	for(int j=1;j<=1000;j++){
		for(int k=1;k<=1000;k++){
			a[i][j][k]+=a[i-1][j][k]+a[i][j+1][k]+a[i][j][k+1];
		}
	}
}

TLE and MLE warnings \color{Cyan}\colorbox{Violet}{TLE and MLE warnings} TLE and MLE warnings

2. Search not memorized

//Memorization Code:
int h[100][100];
int dfs(int n,int m){
	if(h[n][m]) return h[n][m];
	h[n][m]=h[n][m+1]+h[n+1][m];
	return h[n][m];
}

3, Some exam skills I summarized

1. Violence

#include <cstdio>
#include <iostream>
using namespace std;
int main(){
    int sum=0;
    int n;
    scanf("%d",&n);
    for(int a=1;a<=3;a++){
        for(int b=1;b<=3;b++){
            for(int c=1;c<=3;c++){
                for(int d=1;d<=3;d++){
                    for(int e=1;e<=3;e++){
                        for(int f=1;f<=3;f++){
                            for(int g=1;g<=3;g++){
                                for(int h=1;h<=3;h++){
                                    for(int i=1;i<=3;i++){
                                        for(int j=1;j<=3;j++){
                                            if(a+b+c+d+e+f+g+h+i+j==n){
                                                sum++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<sum<<endl;
    for(int a=1;a<=3;a++){
        for(int b=1;b<=3;b++){
            for(int c=1;c<=3;c++){
                for(int d=1;d<=3;d++){
                    for(int e=1;e<=3;e++){
                        for(int f=1;f<=3;f++){
                            for(int g=1;g<=3;g++){
                                for(int h=1;h<=3;h++){
                                    for(int i=1;i<=3;i++){
                                        for(int j=1;j<=3;j++){
                                            if(a+b+c+d+e+f+g+h+i+j==n){
                                                printf("%d %d %d %d %d %d %d %d %d %d\n",a,b,c,d,e,f,g,h,i,j); 
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }   
    return 0;
}
/*
--------
Copyright notice: This is the original article of CSDN blogger "ipraew", which follows the CC 4.0 BY-SA copyright agreement. Please attach the original source link and this notice for reprint.
Original link: https://blog.csdn.net/Athena_Oria/article/details/70195522
*/

The violence procedure depends on the situation.
this some only by hit surface , no can do by Course order ! These are only tables and cannot be used as procedures! These are only tables and cannot be used as procedures!
As the saying goes: violence produces miracles, play a watch! \color{Cyan}\colorbox{Violet} {as the saying goes: violence produces miracles, and the watch shows an example!} As the saying goes: violence produces miracles, play a watch

2. Cheat points.

Look at this question: drop drop hit vehicle Didi taxi Didi taxi
( c a r . c p p ) (car.cpp) (car.cpp)

[problem description]

Xuanxuan and Kaikai are going to kazimi planet to find other children to play my world. Didi taxi launched the "carpooling" activity. For a certain destination, whether a person goes by car or a group of people go together, the total amount of money to be paid is the same (except for the driver, there are up to 4 people in each car).
At this time, many children gathered at the gate of Kaikai'S home. It turned out that they were all ready to take their own modules to kajimi planet. Suppose N children were ready to carpool. At this time, it was time 0. It would cost D yuan to take a taxi from Kaikai'S home to kajimi planet. Kaikai wanted to take a taxi S minutes ago (including the S minute) When we arrive at kajimi planet, because it is too late, the module will break down. Now we give the time Ti when all K taxis reach the gate of Kaikai'S house and the remaining seats Zi in S minutes.
Kaikai thought to himself, "time is money". Kaikai thought that everyone's minutes of waiting for the bus were equivalent to spending the same amount of money (for example, Kaikai waited 40 minutes, which was equivalent to spending an extra 40 yuan).
In the case of ensuring that all children can arrive at the Dakar Jimi planet before the module is damaged, please calculate how much they need to spend at least?

[input format]

The input file name is car.in.
In the first line, there are four integers, N, K, D, S. refer to the topic description for specific meanings.
Next, there are rows K, with two integers Ti and Zi in each row, indicating that the i-th car arrives at Kaikai's door in the Ti minute, and the number of free seats is Zi (the arrival time has been given in order).

[output format]

The output file name is car.out.
Line 1: if all children can get to kajimi planet before the module is damaged, an integer will be output, representing the minimum amount of money (unit: yuan) that all children need to spend. Otherwise, please output "impossible".

[input / output example 1]

car.in	      car.out
2 2 10 5         14
1 1
2 2	

[description of input / output example 1]

Two children take the car that arrives at Kaikai's house in the second minute. Everyone waits for 2 minutes. The minimum cost is 10 + 2 * 2 = 14 yuan.

[data scale and agreement]

For 100% data, N ≤ 100, K ≤ 100, D ≤ 100, S ≤ 100, 1 ≤ Zi ≤ 4, 1 ≤ Ti ≤ Ti+1 ≤ S.

So you just:

#include<bits/stdc++.h>
using namespace std;
int main(){
	cout<<"impossible"; 
	return 0;
}

You can get at least 10 points.

3. Debug DEV-c++


Just turn it into this page!

method:


Check the project management column. Then set the breakpoint and debug slowly. You can simulate the operation of the computer!

4. Write a program to generate random numbers: How to generate random numbers in c + +?

In this way, you can generate another set of data when you are worried about the sample!

total junction no easy , spot individual fabulous again go Yeah ! \color{red} it's not easy to summarize. Just like it before you go! It's not easy to sum up. Just like it before you go!

Posted by ineedhelpbigtime on Mon, 18 Oct 2021 10:20:04 -0700