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 ...
随机推荐
- JAVA数据类型(转)
java中数据的基本类型分为: 基本数据类型和引用数据类型,对此不多介绍: 接下来讨论一下java中数据类型存储在哪 基本数据类型存储在哪,取决于基本类型在哪声明: 1 ...
- Notepad++ QuickText 插件的 HTML 配置: \Notepad++\plugins\Config\QuickText.ini
# 缩写的注解 abbr=<abbr title=''>$</abbr> # 覆盖默认的文本方向 bdo=<bdo dir='rtl'>$</bdo> ...
- 【题解】CF264B Good Sequences
[题解]CF264B Good Sequences 具有很明显的无后效性. 考虑\(dp\). 考虑初始条件,显然是\(dp(0)=0\) 考虑转移,显然是\(dp(t)=max(dp[k])+1\) ...
- [证书服务器 第二篇] 基于OpenSSL 在 CentOS6 系统上 搭建自签证书服务,并应用于Web容器
第一部分:概述 .. 第二部分:环境准备 1 操作系统 CentOS 6.x 2 安装openssl yum install -y openssl 3 安装jdk 从官网下载JDK http://ww ...
- AFNetworking3.0使用简介
注意到咱们集成的版本为3.0.4. 下面的类已从AFNetworking 3.0中废弃: AFURLConnectionOperation AFHTTPRequestOperation AFHTTPR ...
- jQuery 网页禁止复制
<script type="text/javascript"> $(document).ready(function(){ $('#文本框id') ...
- could not read symbols: Archive has no index;
could not read symbols: Archive has no index; run ranlib to add one collect2: ld returned 1 exit sta ...
- python之tkinter_2
关于tkinter的组件介绍,这篇博客很详细: https://www.cnblogs.com/aland-1415/p/6849193.html tkinter is to make interfa ...
- RQNOJ 624 运动鞋:dp
题目链接:https://www.rqnoj.cn/problem/624 题意: 小明有奖学金啦!所以他要去买运动鞋. 总共有n款鞋,分别属于t个品牌. 每款鞋的价格为c[i],在小明心目中的价值为 ...
- (转)Linux内核本身和进程的区别 内核线程、用户进程、用户线程
转自:http://blog.csdn.net/adudurant/article/details/23135661 这个概念是很多人都混淆的了,我也是,刚开始无法理解OS时,把Linux内核也当做一 ...