跳到正文

个人记录

10.9总结

yangziqiao约 8 分钟
原文
文章信息与版本

文章信息

发布
2026年10月11日
收录
2026年10月13日
更新
2026年11月21日
篇幅
约 8 分钟

版本

  1. v1当前

题目列表

A 100 [入门赛 #52] 中秋灯会 30

B 100 「WWOI R4」二五一十 未提交

C 100 Xterfusion 10

D 100 [山东省小学组体验营 2026] 中位数 未提交

A题

❌️错误思路:{\color{red}错误思路:}

  • 暴力直接枚举最初数量

❌️错误结果:{\color{red}错误结果:}

  • 30分
❌️错误代码:{\color{red}错误代码:}
C++
#include<bits/stdc++.h>
using namespace std;
int a[10010][10010];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n,m;
	cin>>n>>m;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i-1][j]==a[i][j])
			{
				ans++;
			}
			if(a[i][j-1]==a[i][j])
			{
				ans++;
			}
			
		}
	}
	
	cout<<ans;
    return 0;
}

✅️正确思路:{\color{green}正确思路:}

  • 每次还原+枚举更换点

✅️

正确代码:{\color{green} 正确代码}\color{green}:
C++
#include<bits/stdc++.h>
using namespace std;
int a[110][110];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n,m;
	cin>>n>>m;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			
			
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			
			int aaa=a[i][j];
			for(int k=1;k<=3;k++)
			{
				a[i][j]=k;
                int cnt=0;
				for(int ii=1;ii<=n;ii++)
				{
					for(int jj=1;jj<=m;jj++)
					{
						
						if(a[ii][jj]==a[ii+1][jj])
						{
							cnt++;
						}
						if(a[ii][jj]==a[ii][jj+1])
						{
							cnt++;
						}
						
					}
				}
				ans=max(ans,cnt);
				
			}
			a[i][j]=aaa;
			
		}
	}
	cout<<ans;
    return 0;
}

B题

❌️错误思路:{\color{red}错误思路:}

  • 无

❌️错误结果:{\color{red}错误结果:}

  • 无
❌️错误代码:{\color{red}错误代码:}
C++
//无

✅️正确思路:{\color{green}正确思路:}

  • 暴力一直删掉最后的零

✅️

正确代码:{\color{green} 正确代码}\color{green}:
C++
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int t;
    cin>>t;
    while(t--)
    {
        long long a;
        cin>>a;
        while(a%5==0)a/=5;
        while(a%2==0)a/=2;
        int cnt=0;
        while(a)a/=10,cnt++;
        cout<<cnt<<'\n';
        
    }
    return 0;
}

C题

❌️错误思路:{\color{red}错误思路:}

  • 骗分

❌️错误结果:{\color{red}错误结果:}

  • 骗分
❌️错误代码:{\color{red}错误代码:}
C++
//无、
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<0;
    return 0;
}

✅️正确思路:{\color{green}正确思路:}

  • 枚举dp

✅️

正确代码:{\color{green} 正确代码}\color{green}:
C++
#include<bits/stdc++.h>
using namespace std;
int dp1[1010];
int dp2[1010];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    s=' '+s;
    int ans=0;
    for(int d=1;d<=n;d++)
    {
        for(int i=1;i<=n;i++)
        {
            if(i>=2*d&&s[i]=='X')dp2[i]=dp2[i-2*d]+1;
            else if(s[i]=='X')dp2[i]=1;
        }
        for(int i=n;i>=1;i--)
        {
            if(i+d<=n&&s[i]=='X')dp1[i]=dp1[i+d]+1;
            else if(s[i]=='X')dp1[i]=1;
        }
        for(int i=1;i<=n;i++)
        {
            ans=max(ans,dp1[i]+dp2[i]-1);
        }
    }
    cout<<ans;
    return 0;
}

D题

❌️错误思路:{\color{red}错误思路:}

  • 无

❌️错误结果:{\color{red}错误结果:}

  • 无
❌️错误代码:{\color{red}错误代码:}
C++
//无

✅️正确思路:{\color{green}正确思路:}

  • 用二分答案来找,找完后 ll就是答案。二分的范围就是−109-10^9 ~ 10910^9

✅️

正确代码:{\color{green} 正确代码}\color{green}:
C++
#include<bits/stdc++.h>
using namespace std;
int n,a[100010];
int check(int x)
{
    int cnt=0;
    int l=1,r=1;
    while(l<=n)
    {
        if(a[l]-x>=r)
        {
            l++;
            r++;
            cnt++;
        }
        else l++;
    }
    return cnt*2>n;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    int l=-2e9,r=2e9;
    while(l+1<r)
    {
        int mid=(l+r)>>1;
        if(check(mid))l=mid;
        else r=mid;
    }
    cout<<l;
    return 0;
}


原文