CF1033C Permutation Game
题目描述
输入输出样例
输入 #1
输出 #1
BAAAABAB
输入 #2
输出 #2
ABAAAABBBAABAAB
数据范围
1<=n<=1e5,1<=ai<=n
解题思路
暴力:略,复杂度玄学
正解:
大佬们都用反建图+拓扑排序
蒟蒻不才 只会dfs
AC Code
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + ;
ll b[N], vis[N], dep[N],num[N], a[N],t, n, m, k,x,y;
int dp[N][];
char v[][];
int dfs(int x,int num) {
if(dp[x][num%]!=-) return dp[x][num%];
else {
dp[x][num%]= (num%==) ? : ;
int did=;
for(int i=;; i++) {
int l=x-i*a[x],r=x+i*a[x];
if(l>=&&a[l]>a[x]) {
if(num%==) dp[x][num%]=max(dp[x][num%],dfs(l,num+)),did=;
else dp[x][num%]=min(dp[x][num%],dfs(l,num+)),did=;
}
if(r<=n&&a[r]>a[x]) {
if(num%==) dp[x][num%]=max(dp[x][num%],dfs(r,num+)),did=;
else dp[x][num%]=min(dp[x][num%],dfs(r,num+)),did=;
}
if(l<&&r>n) break;
}
if(!did) {
return dp[x][num%]=num%;
}
}
return dp[x][num%];
}
int main() {
cin>>n;
for(int i=; i<=n; i++) {
cin>>a[i];
dp[i][]=dp[i][]=-;
}
for(int i=; i<=n; i++) {
if(dfs(i,)) cout<<"A";
else cout<<"B";
}
}
/*
15
3 11 2 5 10 9 7 13 15 8 4 12 6 1 14
*/
CF1033C Permutation Game的更多相关文章
- Permutation Sequence
The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...
- [LeetCode] Palindrome Permutation II 回文全排列之二
Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...
- [LeetCode] Palindrome Permutation 回文全排列
Given a string, determine if a permutation of the string could form a palindrome. For example," ...
- [LeetCode] Permutation Sequence 序列排序
The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the p ...
- [LeetCode] Next Permutation 下一个排列
Implement next permutation, which rearranges numbers into the lexicographically next greater permuta ...
- Leetcode 60. Permutation Sequence
The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...
- UVA11525 Permutation[康托展开 树状数组求第k小值]
UVA - 11525 Permutation 题意:输出1~n的所有排列,字典序大小第∑k1Si∗(K−i)!个 学了好多知识 1.康托展开 X=a[n]*(n-1)!+a[n-1]*(n-2)!+ ...
- Permutation test: p, CI, CI of P 置换检验相关统计量的计算
For research purpose, I've read a lot materials on permutation test issue. Here is a summary. Should ...
- Permutation
(M) Permutations (M) Permutations II (M) Permutation Sequence (M) Palindrome Permutation II
随机推荐
- 数据库服务器和web服务器磁盘占用查询
对于Oracle数据库而言磁盘空间主要体现在表空间上,可使用sql语句进行查看Oracle 表空间的大小及使用情况: select sum(bytes)/1024/1024/1024 "Gb ...
- python 生成文件到- execl
查了一些资料发现是英文版本的 很尴尬,经过看源码,和几个错误 ,现记录下来 一:下载包 pip install xlwt 二:定义样式 def set_style(name, height, bold ...
- 如何在Unity中开发Leap Motion桌面版(Non-VR)APP
最近因需要,翻出几年前的Leapmotion感测器,准备用Unity3D做个互动APP,于是连上官网下载SDK.等下载下来一安装调试,瞬间傻眼,居然要求VR设备.我们Lab倒是不缺VR,有几套VIVE ...
- mysql regexp 表达式
mysql> select * from test; +----+----------+-------+-----------+ | id | name | score | subject | ...
- 行业大秀:EasyEarth Show!
EasyEarth三维可视化地理信息云平台是由北京四维益友信息技术有限公司自主研发的新一代面向三维可视化应用领域的基础信息系统平台. EasyEarth以数据管理为核心,围绕7大类基础数据,提供综合管 ...
- MongoDB 索引 和 explain 的使用
索引基本使用 索引是对数据库表中一列或多列的值进行排序的一种结构,可以让我们查询数据库变得 更快.MongoDB 的索引几乎与传统的关系型数据库一模一样,这其中也包括一些基本的查 询优化技巧. 首先我 ...
- 给lol人物模型添加动画库(mixamo)中的动画
参考链接:https://www.bilibili.com/video/av61771773/?p=4 作为一个懒人,给提取出来的lol人物模型亲手制作动画是不存在的,但是又想给人物模型应用新的有 ...
- Oracle复习思路
目录 Oracle复习 题型 复习大纲 附录 SQL题目一 SQL题目二 SQL题目三 SQL题目四 SQL题目五 SQL题目六 Oracle复习 题型 选择题15题 每题2分,共30分 判断题10题 ...
- 第09组 Beta冲刺(1/4)
队名:软工9组 组长博客:https://www.cnblogs.com/cmlei/ 作业博客:https://edu.cnblogs.com/campus/fzu/SoftwareEngineer ...
- 记某app内购破解 – 安卓逆向菜鸟的初体验
前言 因为某个机缘,我拿到一个赛车app,玩了一会想买个装备,居然要我掏钱包,作为一名cracker,我觉得我的尊严受到了严重的蔑视(无奈钱包空空),我觉得要捍卫我那脆弱的玻璃心(钱包),所以,开干吧 ...