【LGR-148-Div.3】洛谷基础赛 #1 & MGOI Round I

发布时间 2023-08-06 19:04:43作者: The_Shadow_Dragon

【LGR-148-Div.3】洛谷基础赛 #1 & MGOI Round I

T1 luoguP9502 『MGOI』Simple Round I | A. 魔法数字 \(100pts\)

  • 水题,场切了。
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define sort stable_sort 
#define endl '\n'
int main()
{
	int n,m;
	cin>>n;
	m=log2(n);
	if((1<<m)==n)
	{
		if(m%2==1)
		{
			m--;
		}
		else
		{
			m-=2;
		}
	}
	else
	{
		if(m%2==1)
		{
			m--;
		}
	}	
	cout<<m;
	return 0;
}

T2 luoguP9503 『MGOI』Simple Round I | B. 魔法照相馆 \(100pts\)

  • 水题,赛场上当成大模拟了,码风凑合看吧。
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sort stable_sort
#define endl '\n'
int main()
{
	ll n,i,ans=0,r=1,b=1,w=1;
	char pd,en='W';
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>pd;
		if(pd!=en)
		{
			if(en=='W')
			{
				if(pd=='B')
				{
					if(b==1)
					{
						ans++;
					}
					else
					{
						ans+=2;
						b=1;
					}
					w=0;
				}
				if(pd=='R')
				{
					if(r==1)
					{
						if(b==1)
						{
							ans+=2;
							b=0;
						}
						else
						{
							ans++;
						}
					}
					else
					{
						if(b==1)
						{
							ans+=3;
							b=0;
						}
						else
						{
							ans+=2;
						}
					}
					w=0;	
					r=1;
				}
			}
			if(en=='B')
			{
				if(pd=='R')
				{
					if(r==1)
					{
						ans++;
					}
					else
					{	
						ans+=2;
						r=1;
					}
					b=0;
					r=1;
				}
				if(pd=='W')
				{
					ans+=1;	
					w=1;
				}
			}
			if(en=='R')
			{
				if(pd=='W')
				{
					ans+=1;
					w=1;
				}
				if(pd=='B')
				{
					ans+=1;
					b=1;
				}
			}
			en=pd;
		}
	}
	cout<<ans;
    return 0;
}

T3 luoguP9504 『MGOI』Simple Round I | C. 魔法禁林 \(0pts\)

  • 开个坑,准备写。

T4 luoguP9505 『MGOI』Simple Round I | D. 魔法环 \(0pts\)

  • 没做到,咕了。

总结

看清楚题再交,不要像我一样把好几次 \(T3\) 交到了 \(T4\)