当前位置:网站首页>[learning notes] agc010
[learning notes] agc010
2022-07-07 13:09:00 【Ants looking up at the starry sky】
Do more AGC Long brain
No samples , Just rely on your brain
Rearranging
- Consider if two numbers are not mutually prime , Then their relative positions in the final sequence remain unchanged
- So for two numbers that are not coprime , At the same time, orient each edge DAG
- The answer is the largest topological order , Because considering that a point can be exchanged with any other point without entering
- Greedy structure . Start from the point with the lowest number dfs , Find the edge with the lowest node number every time , It can be understood as constructing a tree .
- Then simulate it (
Tiling
- Greedy to consider how to maximize the grid
- Obviously, the mesh is divided into several 2x2 The matrix of is optimal
- The leftover materials are paved with corresponding horizontal bricks or vertical bricks
- This will definitely maximize the number of bricks
- Hand play discovery n=3,m=3,A=2,B=2 There will be problems ( Here hack Data is the difficulty
- That is to say, for the last 2x2 Of the lattice , There is one horizontal brick and one vertical brick left , Theoretically, it can lay two bricks , But due to the shape, only one piece can be paved
- Notice that there is a space in the lower right corner , You can put it down by adjusting .
- There are two schemes directly check that will do .
- Notice the grid problem Nastia and a Beautiful Matrix , from Maximize the use of grid space Starting with , Find the local optimum , Then the global optimal solution is constructed .
Three Circuits
- The degree of each point must be even
- The title gives that this is a connected graph , So there must be an Euler circuit
- If there are degrees of points >=6 , Then there must be a solution ( Consider proving from the perspective of Euler loop
- Count the degree = 4 The number of points is cnt
- If cnt=0 , Then only one ring can be constructed at most
- If cnt=1 , Then only two rings can be constructed at most
- If cnt=2 , So there are two situations ( Drawing perception : It is possible to construct two rings or three rings
- If cnt>=3 , Then remove a simple ring and conclude cnt=2 The situation of , At least three rings can be constructed
Decrementing
- If there is a i = 1 a_i=1 ai=1 , So judge ∑ ( a i − 1 ) \sum{(a_i-1)} ∑(ai−1) Parity .
- Definition ∑ ( a i − 1 ) \sum{(a_i-1)} ∑(ai−1) Odd numbers are wins , Even numbers are negative
- If the person currently operating wins , So no matter what the other person does , At present, this person will win
- Because if you don't divide all numbers by the greatest common divisor , ∑ a i \sum a_i ∑ai The parity of does not change , that ∑ ( a i − 1 ) \sum (a_i-1) ∑(ai−1) The parity of will not change , The outcome is fixed
- Now it's equivalent to ∑ a i → ∑ a i x \sum{a_i}\to \frac{\sum{a_i}}{x} ∑ai→x∑ai , If and only if x x x It's even and ∑ a i x \frac{\sum{a_i}}{x} x∑ai Only when it is an odd number
- Note that the number of odd numbers in the sequence is cnt , At first, because of mutual prime cnt>=1 , Then two people take turns , Those who are behind can never let cnt=0 (n>=3 when )
- If the current operation fails , Then operate on the only odd number , This may reverse the outcome .
- So direct simulation . Not more than log a \log a loga Time .
边栏推荐
- Pay close attention to the work of safety production and make every effort to ensure the safety of people's lives and property
- 怎样重置火狐浏览器
- leecode3. 无重复字符的最长子串
- MySQL导入SQL文件及常用命令
- MongoDB 分片总结
- Sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]
- 【无标题】
- HZOJ #240. Graphic printing IV
- Leetcode skimming: binary tree 25 (the nearest common ancestor of binary search tree)
- 事务的七种传播行为
猜你喜欢
error LNK2019: 无法解析的外部符号
将数学公式在el-table里面展示出来
TPG x AIDU|AI领军人才招募计划进行中!
.Net下極限生產力之efcore分錶分庫全自動化遷移CodeFirst
关于 appium 启动 app 后闪退的问题 - (已解决)
AUTOCAD——大于180度的角度标注、CAD直径符号怎么输入?
关于 appium 如何关闭 app (已解决)
Coscon'22 community convening order is coming! Open the world, invite all communities to embrace open source and open a new world~
Go language learning notes - structure
博文推荐|Apache Pulsar 跨地域复制方案选型实践
随机推荐
Sed of three swordsmen in text processing
[untitled]
博文推荐|Apache Pulsar 跨地域复制方案选型实践
AUTOCAD——大于180度的角度标注、CAD直径符号怎么输入?
API query interface for free mobile phone number ownership
关于 appium 启动 app 后闪退的问题 - (已解决)
test
CMU15445 (Fall 2019) 之 Project#2 - Hash Table 详解
. Net ultimate productivity of efcore sub table sub database fully automated migration codefirst
ORACLE进阶(五)SCHEMA解惑
shell 批量文件名(不含扩展名)小写改大写
服务器到服务器 (S2S) 事件 (Adjust)
详细介绍六种开源协议(程序员须知)
国泰君安证券开户怎么开的?开户安全吗?
货物摆放问题
Unity build error: the name "editorutility" does not exist in the current context
@What is the difference between resource and @autowired?
谷歌浏览器如何重置?谷歌浏览器恢复默认设置?
HZOJ #240. Graphic printing IV
Layer pop-up layer closing problem