B - Black and White Gym - 100801B

2024-04-16 01:08
文章标签 gym black white 100801b

本文主要是介绍B - Black and White Gym - 100801B,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

在这里插入图片描述

题意:
构造一个图使得黑色的四连通块为b个,白色四连通块为w个

思路:
只需要构造两行即可。

ACNEW

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <string>
#include <iostream>
#include <cmath>using namespace std;
typedef long long ll;const int maxn = 1e4 + 7;
char s[maxn];
char a1[maxn],a2[maxn];int main() {freopen("black.in","r",stdin);freopen("black.out", "w", stdout);int b,w;scanf("%d%d",&b,&w);int n = max(b,w) * 2;for(int i = 1;i <= n;i++) {if(i & 1) a1[i] = '.'; //白色else a1[i] = '@';}if(b > w) {for(int i = 1;i <= (b - w) * 2 + 1;i++) {a2[i] = '.';}for(int i = (b - w) * 2 + 2;i <= n;i++) {a2[i] = a1[i];}printf("2 %d\n",n);for(int i = 1;i <= n;i++) printf("%c",a1[i]);printf("\n");for(int i = 1;i <= n;i++) printf("%c",a2[i]);} else if(b < w) {for(int i = n;i >= n - (w - b) * 2;i--) {a2[i] = '@';}for(int i = n - (w - b) * 2 - 1;i >= 1;i--) {a2[i] = a1[i];}printf("2 %d\n",n);for(int i = 1;i <= n;i++) printf("%c",a1[i]);printf("\n");for(int i = 1;i <= n;i++) printf("%c",a2[i]);} else {printf("1 %d\n",n);for(int i = 1;i <= n;i++) {printf("%c",a1[i]);}}return 0;
}
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>using namespace std;int main() {freopen("black.in","r",stdin);freopen("black.out","w",stdout);int b,w;scanf("%d%d",&b,&w);if(b == 1) {printf("%d %d\n",2,w * 2);for(int i = 1;i <= w * 2;i++) {printf("@");}printf("\n");for(int i = 1;i <= w;i++) {printf("@.");}}else if(w == 1) {printf("%d %d\n",2,b * 2);for(int i = 1;i <= b * 2;i++) {printf(".");}printf("\n");for(int i = 1;i <= b;i++) {printf(".@");}printf("\n");}else {printf("%d %d\n",2,(w + b - 2) * 2);for(int i = 1;i <= (w - 1) * 2;i++) {printf("@");}for(int i = 1;i <= (b - 1) * 2;i++) {printf(".");}printf("\n");for(int i = 1;i <= (w - 1);i++) {printf("@.");}for(int i = 1;i <= b - 1;i++) {printf("@.");}printf("\n");}return 0;
}

这篇关于B - Black and White Gym - 100801B的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/907421

相关文章

论文翻译:ICLR-2024 PROVING TEST SET CONTAMINATION IN BLACK BOX LANGUAGE MODELS

PROVING TEST SET CONTAMINATION IN BLACK BOX LANGUAGE MODELS https://openreview.net/forum?id=KS8mIvetg2 验证测试集污染在黑盒语言模型中 文章目录 验证测试集污染在黑盒语言模型中摘要1 引言 摘要 大型语言模型是在大量互联网数据上训练的,这引发了人们的担忧和猜测,即它们可能已

Creating OpenAI Gym Environment from Map Data

题意:从地图数据创建 OpenAI Gym 环境 问题背景: I am just starting out with reinforcement learning and trying to create a custom environment with OpenAI gym. However, I am stumped with trying to create an enviro

【codeforces】gym 101137 K - Knights of the Old Republic【用最小生成树对图做集合dp】

题目链接:【codeforces】gym 101137 K - Knights of the Old Republic 考虑对图集合dp,一个连通块的dp值为两个连通块的值的和或者强制加一条新边后的最小值,取个最小值(边从小到大枚举,则强制加一条最大的边会导致连通块内较小的边一定都选,则会构成一个生成树)。用kruskal实现这个dp过程即可。 #include <bits/stdc++.h>

【codeforces】gym 101138 K. The World of Trains【前缀和优化dp】

题目链接:K. The World of Trains 记录一个横着的前缀dp和以及斜着的前缀dp,复杂度 O(n2) O(n^2) #include <bits/stdc++.h>using namespace std ;typedef pair < int , int > pii ;typedef long long LL ;#define clr( a , x ) memset (

White spaces are required between publicId and systemId.

在配置applicationContext.xml时,编译器报错。 是因为XML的标签顺序导致。 <?xml version="1.0" encoding="UTF-8"?> <beans   xmlns="http://www.springframework.org/schema/beans"    xmlns:xsi="http://www.w3.org/2001/XMLSchema

How to user “Discrete“ object in openai-gym environments?

题意:怎样在 OpenAI Gym 环境中使用 “Discrete” 对象 问题背景: I am trying to create a Q-Learning agent for a openai-gym "Blackjack-v0" environment. I am trying to get the size of the observation space but its in

OpenAI Gym custom environment: Discrete observation space with real values

题意:OpenAI Gym 自定义环境:具有实数值的离散观测空间 问题背景: I would like to create custom openai gym environment that has discrete state space, but with float values. To be more precise, it should be a range of valu

CSS3 文本效果(text-shadow,box-shadow,white-space等)

一 text-shadow text-shadow 属性是 CSS3 中用于为文本添加阴影效果的工具。它可以增强文本的可读性和视觉吸引力,提供丰富的视觉效果 1 语法 text-shadow: offset-x offset-y blur-radius color; offset-x:阴影相对于文本的水平偏移量。可以是正值(向右偏移)或负值(向左偏移)。offset-y:阴影相对于文本的

HDU1312 Red and Black

大致题意:搜索邻接字符到底有多少个 #define LOCAL#include <iostream>#include <fstream>using namespace std;const int maxn = 20 +1;char maze[maxn][maxn];int dx[4] = {0, 1, 0, -1};int dy[4] = {1, 0, -1, 0};int sum;

cocos2d: fullPathForFilename: No file found at /cc_2x2_white_image. Possible missing file.

cocos2d: fullPathForFilename: No file found at /cc_2x2_white_image. Possible missing file. 程序运行的时候输出这条信息cocos2d: fullPathForFilename: No file found at /cc_2x2_white_image. Possible missing file.