Zhengru IOI day3

T1 斯诺克


签到题

code:

#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main()
{
	int r,y,g,b,bl,p,bla;
	cin >> r >> y >> g >> b >> bl >> p >> bla;
	int ans=0;
	if(r==0)
	{
		ans=r*1+y*2+g*3+b*4+bl*5+p*6+bla*7;
		cout << ans << endl;
		return 0;
	}
	for(int i=1;i<=r;i++)
	{
		if(bla!=0)
		{
			ans+=7;
			continue;
		}
		else if(p!=0)
		{
			ans+=6;
			continue;
		}
		else if(bl!=0)
		{
			ans+=5;
			continue;
		}
		else if(b!=0)
		{
			ans+=4;
			continue;
		}
		else if(g!=0)
		{
			ans+=3;
			continue;
		}
		else if(y!=0)
		{
			ans+=2;
			continue;
		}
	}
	ans+=r*1+y*2+g*3+b*4+bl*5+p*6+bla*7;
	cout << ans << endl;
	return 0;
}

T2 翻转


正睿出原题就很淦

100pts大概就是先枚举第一行打那个点

然后依次往后面的几行推

最后不要忘了检查最后一行

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>

using namespace std;

int n,m;
bool mp[23][23];
bool light[23][23];
int cnt=0,ans=0x7ffffff;
int zz;

void shoot(int i,int j)
{
	if(!(i>0&&i<=n&&j>0&&j<=m))
	{
		return ;
	}
	mp[i][j]=!mp[i][j];
	return ;
}
void shooting(int i,int j)
{
	cnt++;
	shoot(i,j);
	shoot(i-1,j);
	shoot(i+1,j);
	shoot(i,j+1);
	shoot(i,j-1);
	return ;
}

void memcpy()
{
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			mp[i][j]=light[i][j];
	return ;
}
int main()
{
	cin >> n >> m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			char ch;
			cin >> ch;
			if(ch=='X')
			{
				light[i][j]=1;
			}
			else light[i][j]=0;
		}
	memcpy();
	int mmx=(1<<m);
	for(;zz<mmx;zz++)
	{
		int szntql=zz;
		int shit=0;
		memcpy();
		cnt=0;
		while(szntql)
		{
			++shit;
			if(szntql&1) shooting(1,shit);
			szntql>>=1;
		}
		for(int i=2;i<=n;i++)
			for(int j=1;j<=m;j++)
				if(mp[i-1][j]) shooting(i,j);
		bool flag=true;
		/*for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				cout << mp[i][j];
			}
			cout << endl;
		}*/
			
		for(int i=1;i<=m;i++)
			if(mp[n][i])
			{
				flag=false;
				break;
			}
		//cout << cnt << endl;
		if(flag) ans=min(cnt,ans);
	}
	cout << ans << endl;
	return 0;
}
posted @ 2021-10-06 16:06  Konjac-Simit  阅读(47)  评论(3)    收藏  举报