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
随机推荐
- Git的基本使用方法(受益匪浅)
git指令介绍,下面有详解指令可以先跳过直接看下面的详解 $ mkdir learngit //创建一个learngit文件夹 $ cd learngit //进入learng ...
- How to change hostname on debian
How to change hostname on Debian 10 Linux last updated July 13, 2019 in CategoriesDebian / Ubuntu, L ...
- 关于System.BadImageFormatException
什么是BadImageFormatException BadImageFormatException是当动态链接库 (DLL) 或可执行程序的文件映像无效时引发的异常. 可能的原因 如果动态链接库 ( ...
- 认识Dump文件
一.什么是Dump文件 又叫内存转储文件或者叫内存快照文件.是一个进程或系统在某一给定的时间的快照.比如在进程崩溃时或则进程有其他问题时,甚至是任何时候,我们都可以通过工具将系统或某进程的内存备份出来 ...
- Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because ...
- c博客作业01——顺序 分支结构
本章学习总结 1.1 学习内容总结 ·学习switch分支的使用,switch后加括号(),括号内填一个变量或字符 如 switch (a) { case 2: case 3: default: } ...
- MSSQL手工注入 报错注入方法
例子:www.kfgtfcj.gov.cn/lzygg/Zixun_show.aspx?id=1[1]首先爆版本:http://www.kfgtfcj.gov.cn/lzygg/Zixun_show. ...
- VLAD算法浅析, BOF、FV比较
划重点 ================================================= BOF.FV.VLAD等算法都是基于特征描述算子的特征编码算法,关于特征描述算子是以SIFT ...
- #C++初学记录(typedef和define)
typedef的用法 typedef关键字可以用于给数据类型定义一个别名,即可以给long long 定义成ll,也可以给结构体定义,当你定义了一个结构体时,每次创建一个结构体都要使用struct+结 ...
- dubbo架构角色
角色 Dubbo有5个参与者:其中Monitor.Registry不是必须的 Provider 暴露服务的服务提供方 Consumer 调用远程服务的服务消费方(负载均衡) Registry 服务注册 ...