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. 2018-2019-2 网络对抗技术 20165235 Exp 9 Web安全基础

    实验任务 本实践的目标理解常用网络攻击技术的基本原理,做不少于7个题目,共3.5分.包括(SQL,XSS,CSRF).Webgoat实践下相关实验. 基础问题回答 (1)SQL注入攻击原理,如何防御 ...

  2. iOS SDK开发之 .framework静态库

    查看.a静态库的生成及使用单击此处 注:这篇教程将只使用一小部分Objective-C代码,本文主要讲解从开始到应用的详细步骤.环境:xcode 9.2下面我们开始操作: 第一步:创建一个静态库工程 ...

  3. c++实验9 图及图的操作实验

    实验9 图及图的操作实验 --博客后半部分有程序的所有代码-- 1.图邻接矩阵存储结构表示及基本操作算法实现 (1)邻接矩阵存储结构类定义: #include "SeqList.h" ...

  4. day66—angularJS学习笔记-表达式

    转行学开发,代码100天——2018-05-21 angular的变量数据初始化: ng-init="quantity=1;cost=30;student={firstName:'李',la ...

  5. 全局namespace与模块内的namespace

    declare global{ declare namespace xxx } 相当于 在一个js文件的顶级部分 declare namespace xxx 声明的都是全局的namespace, 如果 ...

  6. 阶段3 1.Mybatis_08.动态SQL_01.mybatis中的动态sql语句-if标签

    创建新的工程 复制到新建的项目里面 pom.xml依赖部分复制过来 dao中整理代码 只保留四个查询 映射文件也只保留四个查询方法 增加一个根据条件查询的方法. 由于用了别名,所以parpameter ...

  7. HTML5——拖放 地理定位 视频 音频 新的input类型

    拖放 ————>   设置元素为可拖放 拖动什么 放到何处 进行放置 实例[来回拖放] 地理定位 使用地理定位 处理错误和拒绝 在地图中显示结果 基于脚本的交互式地图 给定位置的信息 用户移动时 ...

  8. Android - Retrofit 2.0 使用教程(含实例讲解)

    链接:https://blog.csdn.net/carson_ho/article/details/73732076

  9. c++ 加载库错误问题解决

    转载自:http://blog.csdn.net/sahusoft/article/details/7388617 一般我们在Linux下执行某些外部程序的时候可能会提示找不到共享库的错误, 比如: ...

  10. 【Linux 环境搭建】ubuntu下nfs安装与配置

    (1)安装 #sudo apt-get install nfs-kernel-server portmap(2)修改配置文件 修改/etc/exports,增加以下内容, /root/wksp/roo ...