CF1227C Messy
思路:
构造题。首先把字符串变成“(((((...)))))”的样子,再根据k的取值变成“()()()...((...))”的样子即可。
实现:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int T; cin >> T;
while (T--)
{
int n, k; string s; cin >> n >> k >> s;
vector<pair<int, int>> res;
for (int i = ; i < n / ; i++)
{
if (s[i] == '(') continue;
int j = i + ;
while (j < n && s[j] != '(') j++;
res.push_back(make_pair(i, j));
reverse(s.begin() + i, s.begin() + j + );
}
for (int i = ; i < k - ; i++)
{
int cur = * i + ;
int j = cur + ;
while (j < n && s[j] != ')') j++;
res.push_back(make_pair(cur, j));
reverse(s.begin() + cur, s.begin() + j + );
}
cout << res.size() << endl;
for (auto it: res)
{
cout << it.first + << " " << it.second + << endl;
}
}
return ;
}
CF1227C Messy的更多相关文章
- IOI2016Day2. Messy
题目链接:http://uoj.ac/problem/239 题目大意: 这是一道交互题,交互库维护了一个数据结构,可以存储n为二进制串,一开始你可以向空的数据结构中插入若干二进制串, 接下来这个数据 ...
- Messy Code in Windows Server 2008 R2 English Edition
We always use Windows Server 2008 R2 English operation system. And it doesn't have any problem ...
- the solution about "messy code" in elicpse
I use the Elicpse IDE to develope the ansdroid app.Sometime encounter the messy code in the Elicpse ...
- Chinese Messy Code of String
It's very strange that I found the messy code.I 've never seen this before. this is the java code: / ...
- Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) C. Messy 构造
C. Messy You are fed up with your messy room, so you decided to clean it up. Your room is a bracket ...
- .net 中文显示乱码问题(Chinese display with messy code)
Case:同样的代码,本地开发环境(local is Chinese Simplify)可以成功运行,但是放到Windows Server 2008 R2(Local is United State) ...
- BNU OJ 50998 BQG's Messy Code
#include <cstdio> #define _(l) int l #define ___(l,L) for (_(o)=0,x=l o*2;o<x;o++)O= L o; # ...
- IS Kali: installed chiess messy code problem
apt-get install ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy init 6
- Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3) C Messy
//因为可以反转n次 所以可以得到任何可以构成的序列 #include<iostream> #include<string> #include<vector> us ...
随机推荐
- storm 安装配置
1.1.下载安装包 storm.apache.org 配置zookeeper:http://www.cnblogs.com/eggplantpro/p/7120893.html 1.2.解压安装包ta ...
- Java中实例方法和类方法的区别举例
QAQQAQAQQQAQQAQQAQAQ import java.util.ArrayList; import java.util.Iterator; class myclass{ ; ; publi ...
- LOJ P10116 清点人数 题解
每日一题 day13 打卡 Analysis 用简单的树状数组维护单点修改和查询就行了 #include<iostream> #include<cstdio> #include ...
- 三十二. 多表查询 MySQL管理工具 、 用户授权及撤销
1.MySQL管理工具 部署LAMP+phpMyAdmin平台 安装httpd.mysql.php-mysql及相关包 启动httpd服务程序 解压phpMyAdmin包,部署到网站目录 配置conf ...
- ElasticSearch数据导入By Postman
样例数据 为了更好的使用和理解ES,没有点样例数据还是不好模拟的.这里提供了一份官网上的数据,accounts.json.如果需要的话,也可以去这个网址玩玩,它可以帮助你自定义写随机的JSON数据. ...
- link cut tree 洞穴勘测
/*[bzoj2049][Sdoi2008]Cave 洞穴勘测 2014年7月30日1,06923Description 辉辉热衷于洞穴勘测.某天,他按照地图来到了一片被标记为JSZX的洞穴群地区 . ...
- P1929 迷之阶梯
题目描述 在经过地球防卫小队的数学家连续多日的工作后,外星人发的密码终于得以破解.它 告诉我们在地球某一处的古老遗迹中,存在有对抗这次灾难的秘密武器.防卫小队立即赶 到这处遗迹.要进入遗迹,需要通过一 ...
- NetworkX系列教程(6)-对graph进行操作
小书匠Graph图论 graph生成后,除了有查看操作,还有移除等操作,还有其他更多操作,具体可以看这里.下面将比较graph操作前后的不同. 目录: 7.对图进行操作 7.1移除某些节点和边 7.2 ...
- syniverse是一家怎样的公司
syniverse是一家怎样的公司?(详见问题描述)? 李超 核心业务当然是国际漫游了.简单来说就是做全球各个运营商之间的hub. 打个比方说,一家运营商A做通信,它的覆盖范围肯定是有限的(比如中 ...
- bochs调试命令
Bochs几条基本指令: 通过物理地址查看内存时,可以不加参数'/nuf': 其中n指定显示的单元数,默认是1: u 指定每个显示单元的大小(b表示字节.h表示字(2字节).w表示双字(4字节)),默 ...