Educational Codeforces Round 62 (Rated for Div. 2)



layout: post
title: Educational Codeforces Round 62 (Rated for Div. 2)
author: "luowentaoaa"
catalog: true
tags:
mathjax: true
- codeforces
- dp
---

" target="_blank" style="font-size:24px;">传送门

D - Minimum Triangulation (区间DP,结论题)

思路

一眼看出结论,但是实际上它是个区间DP题,枚举区间\(l-r\)中的一个点\(k\) 然后继续做一个三角形

E - Palindrome-less Arrays (DP)

思路

首先没有大于1的奇数的回文那就是没有长度为3的回文,可以发现只要没有长度为3的回文那就肯定不会有大于长度为3的奇数回文 所以我们就可以把问题拆成奇数和偶数的两个串 要求任意相邻两个不相同的个数

首先如果不是-1答案就已经固定了,如果是-1就考虑这种-1的长度的情况

\(1.\)如果全部都是-1例如\(xxxxx\) 那么我们就直接得到这种有\(k*pow(k-1,n-1)\)

\(2.\)如果是\(axxxx\)或者\(xxxxa\)那么我们就可以直接得到\(pow(k-1,n)\)

\(3.\)如果是\(axxxa\) 那么假设答案就是\(dp[len][1]\)

\(4.\)如果是\(axxxxb\) 那么假设就是\(dp[len][0]\)

首先定义\(dp[len][0]\) 为长度为\(len\)的以上\(3/4\)情况

明显的如果\(len=1\)那么\(dp[len][1]=k-1\) and \(dp[len][0]=k-2\)

现在考虑\(dp[len+1][1]\) 就相当于现在已经有了一个\(axxxxa\)

对于第一个\(x\) 它肯定不是\(a\) 那么他就可能是\(k\)中除了\(a\)之外的\(k-1\)个,所以假设它是\(b\)

那么现在就是\(axxxb\) 发现这个答案我们之前是不是求过了是不是就是\(dp[len][0]\) 啊

然后\(b\)有\(k-1\)中情况所以\(dp[len][1]=(k-1)*dp[len-1][0]\)

另一种同理

原文地址:https://www.cnblogs.com/luowentao/p/10586664.html

时间: 2024-10-08 18:32:18

Educational Codeforces Round 62 (Rated for Div. 2)的相关文章

C. Playlist Educational Codeforces Round 62 (Rated for Div. 2) 贪心+优先队列

C. Playlist time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a playlist consisting of nn songs. The ii-th song is characterized by two numbers titi and bibi — its length and beauty

Educational Codeforces Round 36 (Rated for Div. 2)

Educational Codeforces Round 36 (Rated for Div. 2) F. Imbalance Value of a Tree You are given a tree T consisting of n vertices. A number is written on each vertex; the number written on vertex i is ai. Let's denote the function I(x,?y) as the differ

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars There are n pillars aligned in a row and numbered from 1 to n. Initially each pillar contains exactly one disk. The i-th pillar contains a disk having radius ai. You can move these disks

Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations

原文链接:https://www.cnblogs.com/xwl3109377858/p/11405773.html Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations You are given a sequence of n pairs of integers: (a1,b1),(a2,b2),…,(an,bn). This sequence is called bad if it is

Educational Codeforces Round 36 (Rated for Div. 2) 题解

Educational Codeforces Round 36 (Rated for Div. 2) 题目的质量很不错(不看题解做不出来,笑 Codeforces 920C 题意 给定一个\(1\)到\(n\)组成的数组,只可以交换某些相邻的位置,问是否可以将数组调整为升序的 解题思路 首先如果每个数都能通过交换到它应该到的位置,那么就可以调整为升序的. 但实际上交换是对称的,如果应该在的位置在当前位置前方的数都交换完成,那么整体就是排好序的,因为不可能所有不在相应位置的数都在相应位置的后方.

Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://codeforces.com/contest/985/problem/E Description Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome w

Educational Codeforces Round 55 (Rated for Div. 2)

Educational Codeforces Round 55 (Rated for Div. 2) 链接 A Vasya and Book 傻逼题..注意判边界. #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<set> #include<map> #include<vector> #include<cm

Educational Codeforces Round 57 (Rated for Div. 2)

get人生第二场CF! 成绩:(exACM) rank858 AC3/7 Penalty57 rating1648(+52) 题目:Educational Codeforces Round 57 (Rated for Div. 2) 错题题解: D. Easy Problem E. The Top Scorer F. Inversion Expectation G. Lucky Tickets 原文地址:https://www.cnblogs.com/xht37/p/10198321.html

Educational Codeforces Round 58 (Rated for Div. 2)(待更新)

get人生第七场CF! 成绩:(exACM) rank AC3/7 Penalty104 rating() 题目:Educational Codeforces Round 58 (Rated for Div. 2) 错题题解: C. Division and Union 原文地址:https://www.cnblogs.com/xht37/p/10260260.html