• 2022/11/7(cf·div2·CTR3)https://codeforces.com/contest/1750


    https://codeforces.com/contest/1750/problem/A
    //没看懂,但是根据案例猜出第一项为1输出“YES”;

    #include
    using namespace std;
    #define int long long
    #define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
    #define P pair<int,int>
    #define ft first
    #define sd second
    #define debug(x) cout<<"x="<<x<<'\n'
    const int N=2e5+5;
    int b[N];
    vector<int>v(N);
    
    signed main()
    {
    	int tt;
    	for(cin>>tt;tt--;)
    	{
    		int n;
    		cin>>n;
    		for(int i=0;i<n;i++)
    			cin>>b[i];
    		if(b[0]==1)puts("YES");
    		else puts("NO");
    	}
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25

    https://codeforces.com/contest/1750/problem/B
    //乘积最大,无非三种情况
    //第一种,当0和1的个数都不为0时,xy的情况
    //连续数量最多的0的个数,x
    x的情况
    //连续数量最多的1的个数,y*y的情况

    #include
    using namespace std;
    #define int long long
    #define ios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
    #define P pair<int,int>
    #define ft first
    #define sd second
    #define debug(x) cout<<"x="<<x<<'\n'
    const int N=2e5+5;
    int b[N];
    vector<int>v(N);
    
    signed main()
    {
    	ios;
    	int tt;
    	for(cin>>tt;tt--;)
    	{
    		int n;
    		string s;
    		cin>>n>>s;
    		int x=0,y=0;
    		for(int i=0;i<n;i++)
    		{
    			if(s[i]=='0')x++;
    			else y++;
    		}
    		if(x==0){cout<<y*y<<'\n';continue;}
    		if(y==0){cout<<x*x<<'\n';continue;}
    		int xx=0,yy=0,ans=x*y;
    		for(int i=0;i<n;i++)
    		{
    			if(s[i]=='0')
    			{
    				xx++;
    				ans=max(yy*yy,ans);
    				yy=0;
    			}
    			else
    			{
    				yy++;
    				ans=max(xx*xx,ans);
    				xx=0;
    			}
    		}
    		ans=max(xx*xx,ans);
    		ans=max(yy*yy,ans);
    		cout<<ans<<"\n";
    	}
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50

    https://codeforces.com/contest/1750/problem/C
    //仿tourist的代码
    //注释比较清楚
    //思路差不多,但是我的思路太细节了,根本不用考虑那么多
    //只要不同就操作
    //后面的x数组与y数组是我从cup-ppy学到的,这段代码可以不用x数组和y数组
    //突然觉得auto很神,我要去试试

    #include
    using namespace std;
    #define int long long
    #define ft first
    #define sd second
    int a[200005],b[200005];
    pair<int,int>p[200005];
    
    signed main()
    {
    	int tt;
    	for(cin>>tt;tt--;)
    	{
    		int n;
    		cin>>n;
    		string x,y;
    		cin>>x>>y;
    		int eq=(x==y),dt=1;
    		for(int i=0;i<n;i++)
    		{
    			dt&=(x[i]!=y[i]);
    			a[i+1]=x[i];
    			b[i+1]=y[i];
    		}
    		if(eq==0&&dt==0)//既不全等也不全不同
    		{
    			puts("NO");continue;
    		}
    		
    		//突然发现不用想那么多,把b数组全部弄成相同的就行
    		vector<pair<int,int>>v;
    		for(int i=2;i<=n;i++)
    		{
    			if(b[i]!=b[i-1])
    			{
    				v.emplace_back(1,i-1);
    				swap(eq,dt);//初始a与b相同或相反,每操作一次,相同(相反)会变成相反(相同)
    			}
    		}
    		if(b[1]=='1')//b数组全为1,把它变为全0
    		{
    			v.emplace_back(n,n);
    			v.emplace_back(1,n-1);
    		}
    		if(dt)//a与b不同,把a变得与b相同
    		{
    			v.emplace_back(1,n);
    		}
    		puts("YES");
    		cout<<v.size()<<'\n';
    		for(auto& p:v)
    		{
    			cout<<p.first<<" "<<p.second<<"\n";
    		}
    	}
    }
    //010 010
    //001 110
    //000 000
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
  • 相关阅读:
    Selenium —— 网页frame与多窗口处理!
    论文解读:Sadeepcry:使用自我注意和自动编码器网络的蛋白质结晶倾向预测的深度学习框架
    Kubernetes入门 十六、访问控制
    Robot Arm 机械臂源码解析
    企业或人力资源公司可利用直播将职位以视频直播的方式展现
    【附源码】计算机毕业设计JAVA郑工社团交流服务信息平台
    Lustre和MARTE等建模语言的区别
    MATLAB 函数签名器
    java 企业工程管理系统软件源码+Spring Cloud + Spring Boot +二次开发+ MybatisPlus + Redis
    2022年最新前端面试题
  • 原文地址:https://blog.csdn.net/m0_66433418/article/details/127733598