HDU - 6400 多校8 Parentheses Matrix(构造)
Parentheses Matrix
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Special Judge
- an empty sequence is balanced;
- if A is balanced, then (A) is also balanced;
- if A and B are balanced, then AB is also balanced.
For example, the following parentheses matrix is a 2×4 matrix with goodness 3, because the second row, the second column and the fourth column are balanced:
)()(
()()
Now, give you the width and the height of the matrix, please construct a parentheses matrix with maximum goodness.
Each test case is a single line of two integers h,w (1≤h,w≤200), the height and the width of the matrix, respectively.
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAX = ;
typedef long long LL; int main(void)
{
int t,n,m,i,j;
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&m);
if((n&)&&(m&)){
for(i=;i<=n;i++){
for(j=;j<=m;j++){
printf("(");
}
printf("\n");
}
}
else if(n&){
for(i=;i<=n;i++){
for(j=;j<=m;j++){
if(j&) printf("(");
else printf(")");
}
printf("\n");
}
}
else if(m&){
for(i=;i<=n;i++){
for(j=;j<=m;j++){
if(i&) printf("(");
else printf(")");
}
printf("\n");
}
}
else{
if(n>=m){
for(i=;i<=n;i++){
for(j=;j<=m;j++){
if(i==&&(m/-)>){
printf("(");
continue;
}
if(i==n&&(m/-)>){
printf(")");
continue;
}
if(j==){
printf("(");
continue;
}
if(j==m){
printf(")");
continue;
}
if((i+j)&){
printf(")");
}
else{
printf("(");
}
}
printf("\n");
}
}
else{
for(i=;i<=n;i++){
for(j=;j<=m;j++){
if(j==&&(n/-)>){
printf("(");
continue;
}
if(j==m&&(n/-)>){
printf(")");
continue;
}
if(i==){
printf("(");
continue;
}
if(i==n){
printf(")");
continue;
}
if((i+j)&){
printf(")");
}
else{
printf("(");
}
}
printf("\n");
}
}
}
}
return ;
}
HDU - 6400 多校8 Parentheses Matrix(构造)的更多相关文章
- hdu 6400 Parentheses Matrix
题目链接 Problem Description A parentheses matrix is a matrix where every element is either '(' or ')'. ...
- hdu 2018多校8
A.Character Encoding 简单计数 m个非负数和等于k的方案数为$\binom{m+k-1}{k}$, 但题目还要求每个数小于n, 容斥一下即可 即$ans = \sum\limits ...
- hdu多校第八场Parentheses Matrix
#include<bits/stdc++.h> using namespace std; ][]; int main() { int t; scanf("%d",&am ...
- hdu 5015 233 Matrix(构造矩阵)
http://acm.hdu.edu.cn/showproblem.php?pid=5015 由于是个二维的递推式,当时没有想到能够这样构造矩阵.从列上看,当前这一列都是由前一列递推得到.依据这一点来 ...
- HDU 4671 Backup Plan (2013多校7 1006题 构造)
Backup Plan Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total ...
- HDU多校1003-Divide the Stones(构造)
Problem Description There are n stones numbered from 1 to n.The weight of the i-th stone is i kilogr ...
- HDU 3213 Box Relations(拓扑排序构造)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3231 题意:有n个长方体,四种限制条件.(1)I x y x和y有相交:(2)X/Y/Z x y x ...
- AGC027 D - Modulo Matrix 构造
目录 题目链接 题解 代码 题目链接 AGC027 D - Modulo Matrix 题解 从第左上角第一个点开始染色,相邻不同色,染法唯一 那么一个点的四周与他不同色,我们另这个点比四周都大,那么 ...
- Educational Codeforces Round 48 (Rated for Div. 2) D 1016D Vasya And The Matrix (构造)
D. Vasya And The Matrix time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
随机推荐
- php加速器: xcache
1.准备软件包 xcache-3.2.0.tar.gz 2.安装组件 $ echo 'export LC_ALL=C' >> /etc/profile $ tail -l /etc/pro ...
- php总结5——常量、文件上传
5.1常量 系统常量: PHP_OS 操作系统 PHP_VERSION php版本 PHP_SAPI 运行方式 自定义常量: define("常量名称"," ...
- Ceph集群rbd-mirror A、B区域备份实施方案
Ceph集群rbd-mirror A.B区域备份实施方案 备注:首先准备两个集群, 并确认其状态,集群的准备过程在这就不做陈述 1.查看集群状态 A区域 [root@ceph2111 ceph]# c ...
- 基于GeoEvent Processor的物联网应用案例赏析
1 技术路线 下面全部应用,都採用ArcGIS for Server,结合GeoEvent产品(为一款物联网实时数据集成处理产品)开发完毕. 2 应用场景 1.1 物联网实时态势感知 1.1.1 ...
- 关于LCD的duty与bias
关于LCD的duty与bias 关于LCD的duty与bias duty: 占空比将所有公共电极(COM)各施加一次扫描电压的时间叫一帧,单位时间内扫描多少帧的频率叫帧频,将扫描公共电极(COM)选通 ...
- pkg-config设置
pkg-config在一些源码管理中会被使用到. 介绍 上网查资料,知道了pkg-config这个东西,下面简单介绍一下. pkg-config提供了下面几个功能: 检查库的版本号.如果所需要的库的版 ...
- 关于SQL语句参数中为多个带‘,’的字符串
案例分析:画面为多分数选项,根据画面选择的分数组合=@分数,以SELECT * FROM [table_name] WHERE sore IN (@分数) 其实这不算一个复杂的问题,可能由于着急下班, ...
- jquery 用addClass之后 class有对应的事件,为什么要重新绑定一下事件呢
假设有元素A,B,C,其中A和B都有class属性cls,如果在页面加载完成时,给具有class属性为cls的元素绑定某一事件,例如click,执行事件时调用alert.也就是说,页面加载完成后A和B ...
- Java截取最后一个 _ 后面的所有字符
String file = http://localhost:8888/upload/20190310/115111_58_592_HDFS读取文件的流程.png //截取文件名 String ori ...
- Hadoop- Hadoop详解
首先所有知识以官网为准,所有的内容在官网上都有展示,所有的变动与改进,新增内容都以官网为准.hadoop.apache.org Hadoop是一个开源的可拓展的分布式并行处理计算平台,利用服务器集群根 ...