A

B

C

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int maxn = ;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int main()
{
int ques = ;
int l = ;
int anser = ;
string a;
cin >> a;
int len = a.size();
for (int i = ; i < len - ; i++)
{
l = ;
ques = ;
for (int j = i; j < len; j++)
{
int flag = ;
if (a[j] == ')')
{
l--;
}
else if (a[j] == '(')
{
l++;
}
else
{
ques++;
l--;
}
if (l < )
{
if (ques)
{
while (l < && ques)
{
l += ;
ques--;
}
}
else
{
l = ;
break;
}
}
if (l == )
{
//cout << i << " " << j << endl;
anser++;
}
}
}
cout << anser << endl;
return ;
}

D

A,B轮流走 dp[i][j][k]表示先走的人在i 另一个在j 之前人走的为k时是必胜还是必败 必胜为1 必败为0

#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
const double EPS = 1.0e-4;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int turn[][] = {{, }, { -, }, {, }, {, -}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
vector<int> f[];
int dp[][][];
int gra[][];
int dfs(int x, int y, int now)
{
if (dp[x][y][now] != -)
{
return dp[x][y][now];
}
int len = f[x].size();
for (int i = ; i < len; i++)
{
int to = f[x][i];
if (gra[x][to] >= now && dfs(y, to, gra[x][to]) == )
{
dp[x][y][now] = ;
return ;
}
}
return ;
}
int main()
{
mem(dp, -);
string a;
int n, m;
cin >> n >> m;
for (int i = ; i <= m; i++)
{
char ch;
int from, to;
scanf("%d %d", &from, &to);
cin >> a;
f[from].pb(to);
gra[from][to] = a[] - 'a';
}
for (int i = ; i <= n; i++)
{
for (int j = ; j <= n; j++)
{
if (dfs(i, j, ))
{
cout << "A";
}
else
{
cout << "B";
}
}
cout << endl;
}
return ;
}

Codeforces 918 括号匹配 SGdp[i][j][k]的更多相关文章

  1. The Monster CodeForces - 917A (括号匹配)

    链接 大意:给定字符串, 只含'(',')','?', 其中'?'可以替换为'('或')', 求有多少个子串可以的括号可以匹配 (不同子串之间独立) 记$s_($为'('个数, $s_)$为')'个数 ...

  2. Bracket Sequences Concatenation Problem CodeForces - 990C(括号匹配水题)

    明确一下  一个字符串有x左括号不匹配  和 另一个字符串有x个右括号不匹配  这俩是一定能够匹配的 脑子有点迷 emm... 所以统计就好了  统计x个左括号的有几个,x个右括号的有几个 然后 乘一 ...

  3. UVA 1626 Brackets sequence(括号匹配 + 区间DP)

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=105116#problem/E 题意:添加最少的括号,让每个括号都能匹配并输出 分析:dp ...

  4. C. Serval and Parenthesis Sequence 【括号匹配】 Codeforces Round #551 (Div. 2)

    冲鸭,去刷题:http://codeforces.com/contest/1153/problem/C C. Serval and Parenthesis Sequence time limit pe ...

  5. Codeforces 918C The Monster(括号匹配+思维)

    题目链接:http://codeforces.com/contest/918/problem/C 题目大意:给你一串字符串,其中有'('.')'.'?'三种字符'?'可以当成'('或者')'来用,问该 ...

  6. 集训第五周动态规划 J题 括号匹配

    Description We give the following inductive definition of a “regular brackets” sequence: the empty s ...

  7. Codeforces 5C Longest Regular Bracket Sequence(DP+括号匹配)

    题目链接:http://codeforces.com/problemset/problem/5/C 题目大意:给出一串字符串只有'('和')',求出符合括号匹配规则的最大字串长度及该长度的字串出现的次 ...

  8. CodeForces - 5C(思维+括号匹配)

    题意 https://vjudge.net/problem/CodeForces-5C 给出一个括号序列,求出最长合法子串和它的数量. 合法的定义:这个序列中左右括号匹配. 思路 这个题和普通的括号匹 ...

  9. POJ 2955 Brackets --最大括号匹配,区间DP经典题

    题意:给一段左右小.中括号串,求出这一串中最多有多少匹配的括号. 解法:此问题具有最优子结构,dp[i][j]表示i~j中最多匹配的括号,显然如果i,j是匹配的,那么dp[i][j] = dp[i+1 ...

随机推荐

  1. 新年春节EDM邮件内容设计案例分享

    春节自古以来都是中国最重要的节日.随着中国的发展,中国的春节在世界上都已受到越来越多人的关注,有许多国家和地区都将春节定为法定假日.与此同时,许多品牌营销商也选择在这个时候为中国客户发送马年新年邮件, ...

  2. WPF WebBrowser 加载 html ,出现安全警告, 运行 脚本和 activeX 控件,

    对于你的问题,只需要在你的HTML首行添加如下代码即可隐藏安全提示条: <!-- saved from url=(0014)about:internet --> 还有一个可选方案是使用Wi ...

  3. Collector解读以及自定义

    一.Collector接口解读: Collector接口解读: public interface Collector<T, A, R> { Supplier<A> suppli ...

  4. RESR API (二)之Responses

    Responses 与基本的HttpResponse对象不同,TemplateResponse对象保留 the details of the context that was provided by ...

  5. gitlab在centos7.3上搭建

    gitlab在centos7.3上搭建 最近接到gitlab+jenkins的任务,由于以前只接触过GitHub,并只是简单的使用,这里简单记录gitlab与jenkins搭建的 环境: centos ...

  6. html的标签规范

    if/else标签{ % if condition1 %} ... display 1{ % elif conditon2 %} ... display 2{ % else % } ... displ ...

  7. docker 安装mysql 并将文件挂载到本地

    首先准备好挂载的文件路径 执行mysql创建以及挂载的命令(这里还可以使用-e环境变量来创建新用户MYSQL_USER,MYSQL_PASSWORD) docker run -d -p : --res ...

  8. rename批量修改文件名

    批量改名: 如文件,批量修改,把hello去掉[root@localhost wang]# ll-rw-r--r-- 1 root root 0 5月 14 02:36 a.hello.txt-rw- ...

  9. 第九周课程总结&实验报告七

    实验任务详情: 完成火车站售票程序的模拟. 要求: (1)总票数1000张: (2)10个窗口同时开始卖票: (3)卖票过程延时1秒钟: (4)不能出现一票多卖或卖出负数号票的情况. package ...

  10. 秒懂Vuejs、Angular、React原理和前端发展历史

    「前端程序发展的历史」 「 不学自知,不问自晓,古今行事,未之有也 」 我们都知道现在流行的框架:Vue.Js.AngularJs.ReactJs,已经逐渐应用到各个项目和实际应用中,它们都是MVVM ...