Time：2022-3-11

# 1001、Cut The Wire

Check in and think about it according to the meaning of the question

Opening time: 0:05

Hand in time: 0:39

Problem: the hand speed is slow. Secondly, it is too complex to think about classification, but it can’t think clearly quickly

#include
using namespace std;
typedef long long ll;

int main(){
ios::sync_with_stdio(false);
int T;
cin>>T;
while(T--)
{
ll n;
cin>>n;
If (n% 2 = = 0) // even
{
ll even=ceil(n/2.0);
ll t=ceil((n-1)/3.0);
if (t%2==0) t+=1;
if (3*t+1==n) t+=1;
ll odd=(n-1-t)/2+1;
cout<

# 1002、Time-division Multiplexing

Opening time: around 2:000

Label: string, double pointer, sliding window

Related questions:

Difficulty: read the question and change the meaning (the author also said that the difficulty lies in changing the meaning)

Problems in the competition: reading the question is too slow and the correct code is not selected (originally two points), which leads to tle all the time. It is mistakenly thought that there is a pot at the place where the string is constructed, which delays the overall rhythm of the competition

## meaning of the title

This question has a certain engineering background. The general meaning is that the n-line string has a pointer. Each time, take the character of the current pointer subscript from the first line to the last line, and move the pointer back one bit. When the pointer points to the next bit at the end of the line, return to the 0 subscript, repeat in turn to form a circular string, and find the length of the shortest substring, The string can contain all characters that have appeared.

## thinking

Double pointers are used to solve the shortest substring. The right pointer is put in each time. When the number of different characters contained in the interval of the left and right pointers is equal to the number of characters that have appeared, the answer is updated, and the left pointer is right

Key point: the constructed string needs S + = s, because our answer will appear at the junction of the two strings, which is also something we didn’t expect during the game

## code

#include
using namespace std;
string str;
int p, n;
int leng;
const int INF=0x3f3f3f3f;
bool fun()
{
for (int i = 1; i <= n; i++)
if (0 != p[i])
return false;
return true;
}
int vis;
int main()
{
ios::sync_with_stdio(false);
int T;
cin >> T;
while (T--)
{
cin >> n;
int maxn = -1, pos;
string s = "";
int gcd;
for (int i = 1; i <= n; i++)
{
cin >> str[i];
int len = str[i].size();

if (maxn < len)
maxn = len, pos = i;
p[i] = 0;
leng[i] = len;
}
int sum=0;
memset(vis,0,sizeof vis);
do
{
for (int i = 1; i <= n; i++)
{
int now = p[i];
p[i]++;
if (p[i] >= leng[i])
p[i] = 0;
s += str[i][now];
if (vis[str[i][now]-'a']==0)
sum++;
vis[str[i][now]-'a']=1;
}
} while (!fun());
//The constructed string is s
//cout<

# 1006、Power Sum

Opening: around 0:50

Submitted: 1:28

Teammates did, but when thinking, they thought of the conclusion that the sum of the square difference of two adjacent pairs is equal to 4. They also thought that as long as they can specially construct 1, 2 and 3, they can add 4 continuously. (but the teammate’s hand speed was too fast and cut%% directly)

$-(-(x+1)^2+(x+2)^2)-(x+3)^2+(x+4)^2=4$

$1=1^2$

$2=-1-4-9+16$

$3=-1+4$

$4=1-4-9+16$

## meaning of the title

Given n, let’s pass the following formula, where $$a_ I$$can be 1 or – 1

$\sum\limits_{i=1}^k a_i\times i^2 = n$

Get the sum of the plus and minus squares of 1 ~ k, whose sum is equal to N, and find K and $$a_ I$$’s results

## code

#include
using namespace std;

int main(){
ios::sync_with_stdio(false);
int T;
cin>>T;
while(T--)
{
int n,k=0;
cin>>n;
int cnt=n/4;
n%=4;
string str="";

if (n==1)
str="1",k=1;
else if (n==2)
str="0001",k=4;
else if (n==3)
str="01",k=2;
for(int i=0;i

# 1009、Command sequence

## Meaning:

Give up, down, left and right instructions to find how many substrings can return to the initial point

## thinking

To put it bluntly, ask whether the robot passes through a point more than once. If so, add one to the answer

Up + 1, down – 1, left + 1000007, right – 1000007

If now appears in the map, it means you have been here before

## code

#include
using namespace std;
const int M=1e6+7;
typedef long long ll;
map mp;
int main(){
ios::sync_with_stdio(false);
int T;
cin>>T;
while(T--)
{
ll now=0,res=0;
mp.clear();
int n;
cin>>n;
string cmd;
cin>>cmd;
mp=1;// Back to the starting point
for(int i=0;i

# 1011、Shooting Bricks

This question was read in the last hour of the competition. At that time, I was adjusting question 1002, but I looked at it after I saw that 1011 passed more. The first reaction is greed or DP

But he gave up because he had no idea

It also took an afternoon to figure it out

If the team adds 10021011 questions and about 3 penalty times according to the 0 penalty time in the game, it should be able to reach about rank 300

## meaning of the title

There are n rows and m columns of bricks, each brick has a value, and it takes a bullet to knock out each brick. Some bricks marked ‘y’ don’t cost bullets. Ask: what’s the maximum value you can get when you have K bullets?

## thinking

The idea is based on the explanation of the problem after the game

We convert the bullet cost into space for our backpack model

Let’s preprocess first. How much value can we get by spending CNT bullets on column J

Vy [i] [J] represents the bricks exactly to ‘y’ obtained when spending J in column I

VN [i] [J] represents the bricks exactly to ‘n’ obtained when spending J in column I

FY [i] [J] represents the maximum total value of spending J bullets on column I from column 1 to column I, and just the last one hit the ‘y’ brick

FN [i] [J] represents the maximum total value of spending J bullets on column I from column 1 to column I, and just the last one hit the ‘n’ brick

## code

#include
using namespace std;
const int N=250;
int fy[N][N],fn[N][N],a[N][N],st[N][N],vn[N][N],vy[N][N];

int main(){
ios::sync_with_stdio(false);
int T;
cin>>T;
while(T--)
{
memset(fy,0,sizeof fy);
memset(fn,0,sizeof fn);
memset(vn,0,sizeof vn);
memset(vy,0,sizeof vy);
int n,m,k;
cin>>n>>m>>k;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
char ch;
cin>>a[i][j]>>ch;
st[i][j]=(ch=='Y');
}
//Pretreatment
for(int j=1;j<=m;j++)
{
int cnt=0;
for(int i=n;i>=1;i--)
{
if (st[i][j])
{
vy[j][cnt]+=a[i][j];
//cout<

In the future, 10131012 and remove may be abandoned