当前位置:网站首页>[learning notes] agc041
[learning notes] agc041
2022-07-26 04:25:00 【Ants looking up at the starry sky】
Domino Quality
- atcoder Concise questions are highly praised
Be patient when doing structural problems- What a hell problem ...
- set up ( A , Q ) (A,Q) (A,Q) Indicates that the quantity of each row and column is Q Q Q Of A × A A\times A A×A Matrix of size
- If we knew ( A , Q ) (A,Q) (A,Q) as well as ( B , Q ) (B,Q) (B,Q) Construction method of , We can construct ( A + B , Q ) (A+B,Q) (A+B,Q)
- The specific method is to put the two matrices in the upper left corner and the lower right corner respectively , The rest is empty
- Obviously consider Q = 3 Q=3 Q=3 The situation of
Not obvious - Obviously you can put ( 4 , 3 ) , ( 5 , 3 ) , ( 6 , 3 ) , ( 7 , 3 ) (4,3),(5,3),(6,3),(7,3) (4,3),(5,3),(6,3),(7,3) All were searched out
- Obviously, you can type a watch
Anyway, the test site of this question is not here EH n=7 Why can't violence escapeAlas, with the addition of metaphysical pruning, how can it run fastA pile of code is very ugly, and even the output is very ugly
Unique Path
- Wonderful construction problem
Although I still can't do it - Obviously, delete all edge weights as 1 1 1 The edge of , There is a unique simple path for two points in each connected block
- Don't rush to shrink each connected block , First, we select a point from each connected block , Then connect them into a ring , In this way, there are at least two simple paths for points that are not in the same connected block
- Let the number of connected blocks be k k k( The above structure is just connected k k k side , Form a base ring tree ), Then the number of edges across connected blocks will not exceed k ( k − 1 ) 2 \frac{k(k-1)}{2} 2k(k−1), Otherwise, a connected block cannot maintain its independence
- So we just have to judge m m m Whether the size of is within the range .
- Complexity O ( n ) O(n) O(n).
- summary : Consider the answer Up and down
Wide Swap
Rabbit's solution- Consider a good problem transformation
- set up Q [ i ] Q[i] Q[i] Express i i i Position in the original sequence
- Then exchange Q [ i ] Q[i] Q[i] and Q [ i + 1 ] Q[i+1] Q[i+1] Is the condition of ∣ Q [ i ] − Q [ i + 1 ] ∣ ≥ K |Q[i]-Q[i+1]|\ge K ∣Q[i]−Q[i+1]∣≥K
- If i < j i<j i<j, ∣ Q [ i ] − Q [ j ] ∣ < K |Q[i]-Q[j]|<K ∣Q[i]−Q[j]∣<K that Q [ i ] Q[i] Q[i] and Q [ j ] Q[j] Q[j] The relative position of will not change , let me put it another way Q [ i ] Q[i] Q[i] Forever Q [ j ] Q[j] Q[j] Before
- So let's make Q [ i ] → Q [ j ] Q[i]\to Q[j] Q[i]→Q[j] In this way, the topological order must meet the limit
- At the same time, we need to P P P The order of the dictionary is the smallest , Turn it into 1 1 1 stay Q Q Q Top of the list , stay 1 1 1 Let... Under the premise of the most front 2 2 2 Top
- This is a classic question
Don't be classic anymore. I'm all wa Go over itIt can be solved by reversing the graph and running the maximum topological order - You can consider from small to large according to the number Q [ i ] Q[i] Q[i], We found that as long as we found Q [ i ] Q[i] Q[i] The largest precursor number and the largest subsequent number can be connected .
- Complexity O ( n log n ) O(n\log n) O(nlogn)
Nondivisible Prefix Sums
- Hint1: The sum of all elements cannot be P P P to be divisible by
obviously - Hint2: Mode occurs no more than n 2 \frac{n}{2} 2n The sequence of is legal ( You can think backwards
- Hint3: There is a clever transformation . Let the mode be x x x, Multiply all elements x − 1 x^{-1} x−1, Then the prefix and will also multiply x − 1 x^{-1} x−1
- Hint4:
Clever observationNotice every step P P P Will consume at least one not for 1 1 1 The number of - Why not 1 1 1 At least ∑ i = 1 n y i P \frac{\sum_{i=1}^ny_i}{P} P∑i=1nyi individual
- Consider the construction scheme , First put all the numbers 1 1 1 run out , Then for the rest, as long as we let it not arrive P P P
- Obviously, there is a solution after removing the mode
边栏推荐
- Matlab drawing
- 1. Mx6u-alpha development board (GPIO interrupt experiment)
- P-norm (2-norm is Euclidean norm)
- 【学习笔记】AGC041
- Wu Enda's machine learning after class exercises - linear regression
- Pat class a 1039 course list for student
- Use of rule engine drools
- MySQL日志分类:错误日志、二进制日志、查询日志、慢查询日志
- 图论:拓扑排序
- Sangi diagram of machine learning (for user behavior analysis)
猜你喜欢

egg-ts-sequelize-CLI

Credit card fraud detection based on machine learning

TIA botu WinCC Pro controls the display and hiding of layers through scripts

Build a maker Education Laboratory for teenagers

Spark Structured Streaming HelloWorld

UE4 多个角色控制权的切换

华为高层谈 35 岁危机,程序员如何破年龄之忧?

Acwing_12. 背包问题求具体方案_dp
远坂凛壁纸

荐书丨《教育心理学》:送给明日教师的一本书~
随机推荐
UE4 通过按键控制物体的旋转
荐书 |《学者的术与道》:写论文是门手艺
解析Steam教育的课程设计测评体系
Which websites can I visit to check the latest medical literature?
FFmpeg 视频添加水印
Acwing_ 12. Find a specific solution for the knapsack problem_ dp
建设面向青少年的创客教育实验室
MySQL - multi table query - Cartesian product sum, correct multi table query, equivalent connection and unequal connection, inner connection and outer connection
Function knowledge points
Optimization analysis and efficiency execution of MySQL
1. Mx6u-alpha development board (main frequency and clock configuration experiment)
MySQL日志分类:错误日志、二进制日志、查询日志、慢查询日志
What format should be adopted when the references are foreign documents?
Comparison of the relationship between the number of partitions and the number of reducetask in MapReduce
Life related - less expectation, happier
Support proxy direct connection to Oracle database, jumpserver fortress v2.24.0 release
Huawei issued another global convening order of "genius youth", and some people once gave up their annual salary of 3.6 million to join
Scroll view pull-down refresh and pull-up load (bottom)
Retail chain store cashier system source code management commodity classification function logic sharing
VM虚拟机 没有未桥接的主机网络适配器 无法还原默认配置