Codeforces 1023 C.Bracket Subsequence-STL(vector) (Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Fi)
。。。
代码:
1 //C
2 #include<iostream>
3 #include<cstdio>
4 #include<cstring>
5 #include<algorithm>
6 #include<bitset>
7 #include<cassert>
8 #include<cctype>
9 #include<cmath>
10 #include<cstdlib>
11 #include<ctime>
12 #include<deque>
13 #include<iomanip>
14 #include<list>
15 #include<map>
16 #include<queue>
17 #include<set>
18 #include<stack>
19 #include<vector>
20 using namespace std;
21 typedef long long ll;
22
23 const double PI=acos(-1.0);
24 const double eps=1e-6;
25 const ll mod=1e9+7;
26 const int inf=0x3f3f3f3f;
27 const int maxn=2*1e5+10;
28 const int maxm=100+10;
29 #define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
30
31 char a[maxn];
32
33 int main()
34 {
35 ios;
36 int n,k;
37 cin>>n>>k;
38 cin>>a;
39 vector<char> ans;
40 int temp=k/2,sum1=0,sum2=0;
41 for(int i=0;i<n;i++){
42 if(sum1<temp&&a[i]=='('){
43 ans.push_back(a[i]);
44 sum1++;
45 }
46 if(a[i]==')'&&sum2<sum1){
47 ans.push_back(a[i]);
48 sum2++;
49 }
50
51 }
52 for(int i=0;i<k;i++)
53 cout<<ans[i];
54 cout<<endl;
55 }
Codeforces 1023 C.Bracket Subsequence-STL(vector) (Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Fi)的更多相关文章
- Codeforces 1023 A.Single Wildcard Pattern Matching-匹配字符 (Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Fi)
Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) A. Single Wildcard Patter ...
- Codeforces 1023 D.Array Restoration-RMQ(ST)区间查询最值 (Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Fi)
D. Array Restoration 这题想一下就会发现是只要两个相同的数之间没有比它小的就可以,就是保存一下数第一次出现和最后一次出现的位置,然后查询一下这个区间就可以,如果有0的话就进行填充. ...
- Codeforces 1023 B.Pair of Toys (Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Fi)
B. Pair of Toys 智障题目(嘤嘤嘤~) 代码: 1 //B 2 #include<iostream> 3 #include<cstdio> 4 #include& ...
- Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-C-Bracket Subsequence
#include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> ...
- E - Down or Right Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
http://codeforces.com/contest/1023/problem/E 交互题 #include <cstdio> #include <cstdlib> #i ...
- D. Recovering BST Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
http://codeforces.com/contest/1025/problem/D 树 dp 优化 f[x][y][0]=f[x][z][1] & f[z+1][y][0] ( gcd( ...
- Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3) F 构造
http://codeforces.com/contest/967/problem/F 题目大意: 有n个点,n*(n-1)/2条边的无向图,其中有m条路目前开启(即能走),剩下的都是关闭状态 定义: ...
- Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3) E 贪心
http://codeforces.com/contest/967/problem/E 题目大意: 给你一个数组a,a的长度为n 定义:b(i) = a(1)^a(2)^......^a(i), 问, ...
- Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3) D 贪心
http://codeforces.com/contest/967/problem/D 题目大意: 有n个服务器,标号为1~n,每个服务器有C[i]个资源.现在,有两个任务需要同时进行,令他为x1,x ...
随机推荐
- ASP.NET页面之间传值Server.Transfer(4)
这个才可以说是面象对象开发所使用的方法,其使用Server.Transfer方法把流程从当前页面引导到另一个页面中,新的页面使用前一个页面的应答流,所以这个方法是完全面象对象的,简洁有效. Serve ...
- BZOJ4513 SDOI2016储能表(数位dp)
如果n.m.k都是2的幂次方,答案非常好统计.于是容易想到数位dp,考虑每一位是否卡限制即可,即设f[i][0/1][0/1][0/1]为第i位是/否卡n.m.k的限制时,之前的位的总贡献:g[i][ ...
- HDOJ.2501 Tiling_easy version
Tiling_easy version Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 原生ajax方法封装
/** * @function ajax request * @fields ajaxName:请求名称,method:请求方法,headers:setRequestHeader自定义部分,url:接 ...
- Educational Codeforces Round 55 (Rated for Div. 2):E. Increasing Frequency
E. Increasing Frequency 题目链接:https://codeforces.com/contest/1082/problem/E 题意: 给出n个数以及一个c,现在可以对一个区间上 ...
- 解析json方式之net.sf.json
前面转载了json解析的技术:fastjson,今天说下另外一种技术. 下载地址 本次使用版本:http://sourceforge.net/projects/json-lib/files/json- ...
- CRM系统主要业务流程思维导图
[CRM五策略] ❶对客户进行分类,不是根据规模,而是根据和你的关系,越细腻越好: ❷不定期更新客户资料,信息越全面越好: ❸主动对客户进行 ...
- Elasticsearch 5.2.1Cluster 搭建
1.安装java cd ~ wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fw ...
- 【SPOJ-QTREE】树链剖分
树链剖分学习 https://blog.csdn.net/u013368721/article/details/39734871 https://www.cnblogs.com/George1994/ ...
- NGINX: 反向代理 websocket
参考: [ Using multiple nodes ] [ Nginx 官网 WebSocket proxying ] 关于 websocket 的介绍可以看阮大大的这篇 [ WebSocket 教 ...