跳到正文

题解

AT3979(ARC093B)

dottle约 2 分钟
原文
文章信息与版本

文章信息

发布
2022年9月1日
收录
2026年10月14日
更新
2026年11月10日
篇幅
约 2 分钟
获赞
9

版本

  1. v1当前

对于所有数据,我们都构造一个 100×100100\times 100 的矩阵。然后:

  1. 将上半部分涂白,下半部分涂黑。
  2. 选择上半部分的 B−1B-1 个格子不相邻且不会把白色隔断的格子涂黑,选择下半部分的 A−1A-1 个这样的格子涂白。

示意图:

img

C++
#include<bits/stdc++.h>
#define int long long
const int N=155;
using namespace std;

char col[N][N];
const int A=50,B=100;

void solve(){
	int a,b;cin>>a>>b;
	a--,b--;
	cout<<B<<' '<<B<<endl;
	for(int i=1;i<=A;i++)
		for(int j=1;j<=B;j++){
			col[i][j]='.';
			col[i+A][j]='#';
		}
	for(int i=2;b;i+=2)
		for(int j=2;b&&j<=B;j+=2)
			col[i][j]='#',b--;
	for(int i=52;a;i+=2)
		for(int j=2;a&&j<=B;j+=2)
			col[i][j]='.',a--;
	for(int i=1;i<=B;i++){
		for(int j=1;j<=B;j++)
			cout<<col[i][j];
		cout<<endl;
	}
}

main(){
	ios::sync_with_stdio(0);
	int _T=1;//cin>>_T;
	while(_T--)solve();
}