题目描述

输入输出样例

输入 #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的更多相关文章

  1. Permutation Sequence

    The set [1,2,3,-,n] contains a total of n! unique permutations. By listing and labeling all of the p ...

  2. [LeetCode] Palindrome Permutation II 回文全排列之二

    Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...

  3. [LeetCode] Palindrome Permutation 回文全排列

    Given a string, determine if a permutation of the string could form a palindrome. For example," ...

  4. [LeetCode] Permutation Sequence 序列排序

    The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the p ...

  5. [LeetCode] Next Permutation 下一个排列

    Implement next permutation, which rearranges numbers into the lexicographically next greater permuta ...

  6. 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 ...

  7. UVA11525 Permutation[康托展开 树状数组求第k小值]

    UVA - 11525 Permutation 题意:输出1~n的所有排列,字典序大小第∑k1Si∗(K−i)!个 学了好多知识 1.康托展开 X=a[n]*(n-1)!+a[n-1]*(n-2)!+ ...

  8. 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 ...

  9. Permutation

    (M) Permutations (M) Permutations II (M) Permutation Sequence (M) Palindrome Permutation II

随机推荐

  1. LeetCode 842. Split Array into Fibonacci Sequence

    原题链接在这里:https://leetcode.com/problems/split-array-into-fibonacci-sequence/ 题目: Given a string S of d ...

  2. Spark-源码分析01-Luanch Driver

    1.SparkSubmit.scala 什么是Driver 呢?其实application运行的进程 就是driver,也是我们所写的代码就是Driver. object DefaultPartiti ...

  3. mac系统下 PHPStorm 快捷键

    PHPStorm可以自己设置快捷键 按住command + , 打开Preferences点击Keymap,右边出现下拉框点击下拉框选择你想要的快捷键设置,eclipse快捷键比较常用 eclipse ...

  4. 超级好用的excel导出方法,比phpexcel快n倍,并且无乱码

    public function exportToExcel($filename, $tileArray=[], $dataArray=[]){ ini_set('memory_limit','512M ...

  5. Ajax 的一些概念 解析

    什么是Ajax Ajax基本概念 Ajax(Asynchronous JavaScript and XML):翻译成中文就是异步的JavaScript和XML. 从功能上来看是一种在无需重新加载整个网 ...

  6. mysql 分组和排序

    mysql> select * from table1; +----------+------------+-----+---------------------+ | name_new | t ...

  7. 证书转化 .cer .crt .jks

    cer格式——>JKS (keytool 为java JDK自带的,可以在bin目录下找到) keytool -import -alias mycert -file d:\def.cer -ke ...

  8. DIV块中 元素垂直居中

    1 DIV块中 元素垂直居中 作者:知乎用户链接:https://www.zhihu.com/question/20543196/answer/99429177来源:知乎著作权归作者所有.商业转载请联 ...

  9. Cesium学习笔记-工具篇20-PrimitiveTexture自定义渲染-贴图【转】

    前几篇博客我们了解了自定义点.线.面绘制,这篇我们接着学习cesium自定义纹理贴图.我们完成点线面的绘制,只是绘制出了对象的框架,没有逼真的外观.逼真外观是需要设置材质来实现:Material . ...

  10. Netty对WebSocket的支持

    WebSocket长连接 一.创建服务端代码 1.MyServer 类 public class MyServer { public static void main(String[] args) t ...