跳到正文

个人记录

10.16总结

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

文章信息

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

版本

  1. v1当前

题目列表

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

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

C 100 Xterfusion 10

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

A题

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

  • 暴力 代码跟正确代码差不多 思路一样

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

  • 20分
❌️错误代码:{\color{red}错误代码:}
C++
#include<bits/stdc++.h>
using namespace std;
int n,m,q;
int a[10010][10010];
int main(){
//    ios::sync_with_stdio(false);
//    cin.tie(0);
//    cout.tie(0);

    cin>>n>>m>>q;
    int cnt=1;
    while(q--)
    {
    	int op;
    	cin>>op;
    	if(op==1)
    	{
    		int x,y,h,w,f=0;
    		cin>>x>>y>>h>>w;
    		if(x+h-1>n||y+w-1>m)
    		{
    			cout<<"Error"<<'\n';
	    		f=1;
			}
    		for(int i=x;i<=x+h-1;i++)
    		{
    		
				for(int j=y;j<=y+w-1;j++)
	    		{
	    			if(a[i][j]!=0)
	    			{
	    				cout<<"Error"<<'\n';
	    				f=1;
					}
				}
    			
			}
    		
			if(f==0)
			{
				for(int i=x;i<=x+h-1;i++)
	    		{
	    		
					for(int j=y;j<=y+w-1;j++)
		    		{
		    			a[i][j]=cnt;
					}
	    			
				}
				cout<<cnt<<'\n';cnt++;
			}
			
			
			
			
		}
		else if(op==2)
    	{
    		int id;
    		cin>>id;
    		int f=0;
    		for(int i=1;i<=n;i++)
    		{
    			for(int j=1;j<=m;j++)
    			{
    				if(a[i][j]==id)
    				{
    					a[i][j]=0;
    					f=1;
					}
				}
			}
			if(f==0)
			{
				cout<<"Error\n";
			}
			else cout<<"Remove\n";
		}
		else if(op==3)
		{
			int x,y;
			cin>>x>>y;
			cout<<a[x][y]<<'\n';
		}
	}
	int ans=0;
	map<int,int>mp;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]!=0)
			{
				mp[a[i][j]]++;
				ans++;
			}
		}
	}
	cout<<mp.size()<<' '<<ans<<'\n';
    return 0;
}

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

  • 暴力

✅️

正确代码:{\color{green} 正确代码}\color{green}:
C++
#include<bits/stdc++.h>
using namespace std;
int n,m,q;
int a[10010][10010];
int main(){
//    ios::sync_with_stdio(false);
//    cin.tie(0);
//    cout.tie(0);

    cin>>n>>m>>q;
    int cnt=0;
    while(q--)
    {
    	int op;
    	cin>>op;
    	if(op==1)
    	{
    		int x,y,h,w;
    		cin>>x>>y>>h>>w;
    		if(x+h-1>n||y+w-1>m)
    		{
    			cout<<"Error"<<'\n';
	    		continue;
			}
            int f=0;
    		for(int i=x;i<=x+h-1;i++)
    		{
    		
				for(int j=y;j<=y+w-1;j++)
	    		{
	    			if(a[i][j])
	    			{
	    				
	    				f=1;
					}
				}
    			
			}
    		
			if(f==0)
			{
                cnt++;
				for(int i=x;i<=x+h-1;i++)
	    		{
	    		
					for(int j=y;j<=y+w-1;j++)
		    		{
		    			a[i][j]=cnt;
					}
	    			
				}
				cout<<cnt<<'\n';
			}
            else cout<<"Error\n";
			
			
			
			
		}
		else if(op==2)
    	{
    		int id;
    		cin>>id;
    		int f=0;
    		for(int i=1;i<=n;i++)
    		{
    			for(int j=1;j<=m;j++)
    			{
    				if(a[i][j]==id)
    				{
    					a[i][j]=0;
    					f=1;
					}
				}
			}
			if(f)
			{
				cout<<"Remove\n";
			}
			else cout<<"Error\n";
		}
		else if(op==3)
		{
			int x,y;
			cin>>x>>y;
			cout<<a[x][y]<<'\n';
		}
	}
	int ans=0;
	map<int,int>mp;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(a[i][j])
			{
				mp[a[i][j]]++;
				ans++;
			}
		}
	}
	cout<<mp.size()<<' '<<ans<<'\n';
    return 0;
}

B题

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

  • 无

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

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

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

  • 枚举所有满足条件的ii,然后将所有ii的倍数的位置都标上ii,其余位置标上11。

✅️

正确代码:{\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--)
    {
    	int n;
    	cin>>n;
    	int a[10001][10010];
        for(int i=1;i<=n;i++)
    	{
    		for(int j=1;j<=n;j++)
            {
                a[i][j]=1;
                
            }
		}
    	for(int i=2;i<=n;i++)
    	{
    		for(int j=i;j<=n;j+=i)
            {
                a[i][j]=i;
                a[j][i]=i;
            }
		}
        for(int i=1;i<=n;i++)
    	{
    		for(int j=1;j<=n;j++)
            {
                cout<<a[i][j]<<' ';
            }
            cout<<'\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<<"无";//无
    return 0;
}

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

  • 每输入一个圆,枚举一遍圆中所有点,用勾股定理求出所有距离圆心不超过半径的点标记一下,最后根据标记求出答案

✅️

正确代码:{\color{green} 正确代码}\color{green}:
C++
#include<bits/stdc++.h>
using namespace std;
int cnt[10010][10010];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	int x,y,r;
    	cin>>x>>y>>r;
    	for(int xx=1;xx<=1000;xx++)
    	{
    		for(int yy=1;yy<=1000;yy++)
    		{
    			if((x-xx)*(x-xx)+(y-yy)*(y-yy)<=r*r)
    			cnt[xx][yy]++;
			}
		}
    		
	}
    int q;
    cin>>q;
    while(q--)
    {
    	int x,y;
    	cin>>x>>y;
    	if(cnt[x][y]%2)cout<<"Yes"<<'\n';
    	else cout<<"No"<<'\n';
	}
    return 0;
}

D题

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

  • 无

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

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

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

  • 我们可以在每次操作中让aia^i变成aia^i异或kk之后比原来大多少,这道题就变成了最大子段和和最小子段和,就可以用DPDP做了

✅️

正确代码:{\color{green} 正确代码}\color{green}:
C++
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[10010],b[10010];
int dp[10010],dp1[10010];
int n,m;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin>>n>>m;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
    	ans+=a[i];
	}
    
    while(m--)
    {
    	int k;
        cin>>k;
        for(int i=0;i<=n;i++)
        {
            dp[i]=dp1[i]=0;
            b[i]=(a[i]^k)-a[i];
        }
        int mmax=-1e18,mmin=1e18;
        for(int i=1;i<=n;i++)
        {
            dp[i]=max(b[i],dp[i-1]+b[i]);
            dp1[i]=min(b[i],dp1[i-1]+b[i]);
            mmax=max(mmax,dp[i]);
            mmin=min(mmin,dp1[i]);
        }
        cout<<ans+mmin<<' '<<ans+mmax<<'\n';
	}
    return 0;
}
原文