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. zay大爷的神仙题目 D1T1-大美江湖

    在前几天的时候,千古神犇zay(吊打zhx那个)出了一套神仙题目,所以我得来分析分析QWQ 先补个网易云链接QWQ 毕竟是T1嘛,还算是比较简单的,那道题,读完题目就发现是个中等模拟(猪国杀算大模拟的 ...

  2. 安装telnet服务

    一.安装telnet1.检测telnet-server的rpm包是否安装 [root@localhost ~]# rpm -qa telnet-server 若无输入内容,则表示没有安装.出于安全考虑 ...

  3. Spring mvc注解说明

    编号 注解 说明 位置 备注 1 @Controller 将类变成Spring Bean 类 现阶段 @Controller . @Service 以及 @Repository 和 @Componen ...

  4. fiddler之模拟请求超时和弱网模式

    在针对手机端测试时,很多情况下我们需要测试响应超时和弱网情况的响应情况.此时可以使用fiddler提供的断点和弱网功能进行测试. 1.请求超时 设置断点,是请求响应超时.查看请求结果. Rules-- ...

  5. 2 日志系统:一条sql更新语句是如何执行的?

    2 日志系统:一条sql更新语句是如何执行的? 前面了解了一个查询语句的执行流程,并介绍了执行过程中涉及的处理模块,一条查询语句的执行过程一般是经过连接器.分析器.优化器.执行器等功能模块,最后达到e ...

  6. 判断Ctrl Shift Alt 键当前是否被按下

    Control.ModifierKeys.HasFlag(Keys.Shift) 以此类推

  7. 一文学会Go - 2 数据结构与算法实践篇

    练习:使用go语言实现冒泡排序和归并排序 冒泡排序是所有排序算法中最简单的,练习时先实现它: func bubbleSort(array []int) { n := len(array) ; j &l ...

  8. jmeter常用性能监听器分析

    jmeter中提供了很多性能数据的监听器,我们通过监听器可以来分析性能瓶颈 本文以500线程的阶梯加压测试结果来描述图表. 常用监听器 1:Transactions per Second 监听动态TP ...

  9. 【MM系列】SAP MM模块-收货自动创建采购订单

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP MM模块-收货自动创建采购订 ...

  10. debian上安装mysql server

    1 将mysql添加到apt的repository中 第一步,下载mysql提供的ppa文件 wget https://dev.mysql.com/get/mysql-apt-config_0.8.1 ...