# [CSDN Contest Issue 6] Programming Contest Summary

CSDN programming contest registration address: https://edu.csdn.net/contest/detail/16

## Foreword/Background

At present, I have participated in 5 CSDN programming competitions in a row. This kind of competition is very meaningful. I hope it will continue to be held!

## Problem and problem solving code

There are four questions this time. Compared with the previous ones, the questions in this issue are relatively simple, so a bunch of people got full marks (including me). All the problems can be solved directly by violence, here is the code of my problem solving at that time.

```#include <iostream>
#include <string>
#include <sstream>
#include <vector>
int solution(int n, std::vector<std::string>& vec){
int result=0;
// TODO:
for(int i=0;i<n;i++){
if(vec[i].size()>=2&&vec[i].size()<=4){
if(vec[i]=="ak")result++;
else if(vec[i]=="m4a1")result++;
else if(vec[i]=="skr")result++;
else continue;
}
}return result;
}
int main() {
int n;
std::vector<std::string> vec;
std::cin>>n;
for (size_t i = 0; i < n; i++){
std::string s;
std::cin>>s;
vec.push_back(s);
}
int result = solution(n,vec);
std::cout<<result<<std::endl;
return 0;
}
```

Just use a map to store the number, and then select the largest number.

```#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include<map>
std::string solution(int n, std::vector<std::string>& vec){
std::string result;
// TODO:
std::map<std::string,int>mp;
for(size_t i=0;i<n;i++){
mp[vec[i]]++;
}int max_val = 0;
for(size_t i=0;i<n;i++){
if(mp[vec[i]]>max_val){
max_val = mp[vec[i]];
result=vec[i];
}
}
return result;
}
int main() {
int n;
std::vector<std::string> vec;
std::cin>>n;
for (size_t i = 0; i < n; i++){
std::string s;
std::cin>>s;
vec.push_back(s);
}
std::string result = solution(n,vec);
std::cout<<result<<std::endl;
return 0;
}
```

```#include <iostream>
#include <string>
#include <sstream>
#include <vector>
std::string solution(std::string str){
std::string result="";
// TODO:
int flag=0;
for(size_t i=0;i<str.size();i++){
if(!flag&&i>0&&i<str.size()-2&&str[i]=='a'&&str[i+1]=='t'){
result += '@';
flag=1;
i+=1;
}else if(i>0&&i<str.size()-3&&str[i]=='d'&&str[i+1]=='o'&&str[i+2]=='t'){
result+='.';
i+=2;
}else{
result+=str[i];
}
}
return result;
}
int main() {
std::string str;
std::cin>>str;
std::string result = solution(str);
std::cout<<result<<std::endl;
return 0;
}
```

This problem is to find the length of the longest increasing subarray, so it is enough to solve it directly with two pointers. If you want to solve the length of the longest increasing subsequence, you can use dynamic programming.

```#include <iostream>
#include <string>
#include <sstream>
#include <vector>
int solution(int n, std::vector<int>& vec){
// TODO:
if(n<=1)return n;
int result = 1;
int start = 0;
int end = 1;
for(int i=1;i<n;i++){
if(vec[i]>vec[i-1]){
end++;
}else{
start=i;
end=i+1;
}
result = result>end-start?result:end-start;
}
return result;
}
int main() {
int n;
std::cin>>n;
std::vector<int> vec(n);
for(int i=0;i<n;i++){
std::cin>>vec[i];
}
int result = solution(n,vec);
std::cout<<result<<std::endl;
return 0;
}
```

## Experience

This time, because the topic is relatively simple, the topic itself is actually not of reference value. However, from the perspective of doing the question, I think that the core code mode like CSDN requires first to figure out the input and output given by the system, and sometimes it is necessary to question whether there is a problem with the input and output given by the system, there is a problem If so, you can rewrite the input and output directly according to the meaning of the question.

## Suggest

For CSDN's competition system, combined with the experience of participating in the past, I mainly feel that the following points can be improved:

1. Copy and paste between your own codes in the page will still record the number of times, which is not a good experience;
2. After compiling the error, the error description can be clearer, try to be as easy to understand as Likou;
3. The last point, which is also a point that people complain about in every issue, is the anti-cheating mechanism. Every time I see the top gods in a few minutes, I can't help but think that there is something tricky (of course I don't deny that there is such a thing). awesome god). If it is held in the later stage, I feel that the time-limited entry time can be shortened. For example, if the test starts at 10:30, then the system cannot be entered after 15 minutes of the test, similar to this mechanism.
4. Another point, the e-book monthly card reward, please change it to another reward next time, this is too tasteless. . .

Posted by cjdesign on Sat, 24 Sep 2022 22:58:41 +0530