原创 cf1183 F. Topforces Strikes Back

鏈接 點擊跳轉 先考慮選擇兩個數字滿足條件且和最大 假設我只要選擇兩個數字,那麼一種可能很好的方案就是先選擇最大的數字,再選一個不是其約數的數字中最大的 假設我原序列按照升序排列,最大的數字是ana_nan​,最大的不是其約數的數

原创 cf1236D. Alice and the Doll

鏈接 點擊跳轉 題解 用dequedequedeque維護每行每列的黑格子位置,然後每次pop_front掉不合法的,找到我走到的位置,跳過去,記錄走過的總路程 最後看下總路程是不是等於nm−knm-knm−k 代碼 #inclu

原创 2019上海站網絡預選賽 C.Triple

鏈接 點擊跳轉 題解 FFT 代碼 #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy

原创 cf478B. Strip

鏈接 點擊跳轉 題解 dpdpdp 用線段樹+二分查詢當前結尾能符合條件的最長區間 然後線段樹更新答案 代碼 #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container

原创 cf375D. Tree and Queries

鏈接 點擊跳轉 題解 用dsu on tree艹過去了… 這題也可以莫隊 代碼(dsu on tree) #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.h

原创 2019南昌網絡賽H.The Nth Item

鏈接 點擊跳轉 題解 特徵根法解除斐波那契額通項: 根據遞推式F(n)=3F(n−1)+2F(n−2)F(n)=3F(n-1)+2F(n-2)F(n)=3F(n−1)+2F(n−2) 設x2=3x+2x^2 = 3x + 2x2=

原创 cf484D. Kindergarten

鏈接 點擊跳轉 題解 這題感覺就是要瞎分析一波然後莽 可以發現分成的每一段都是單調的 但是端點處不一定屬於哪邊,這個時候dpdpdp一下就好了 代碼 #include <bits/stdc++.h> #include <ext/p

原创 cf825E. Minimal Labels

鏈接 點擊跳轉 題解 倒着貪心,每次把最大的序號給編號最大的出度爲000的點 可以用反證法證明 而正着搞是錯的 代碼 #include <bits/stdc++.h> #include <ext/pb_ds/assoc_conta

原创 cf519E. A and B and Lecture Rooms

鏈接 點擊跳轉 題解 如果兩個點的距離是奇數,無解 如果兩個點的距離是偶數,那麼肯定路徑的中點滿足條件,然後想象以這個中點爲根建樹,只要接下來不走到aaa或bbb所在的子樹就可以 代碼 #include <bits/stdc++.

原创 cf617E. XOR and Favorite Number

鏈接 點擊跳轉 題解 被越界搞得頭皮發麻… sis_isi​表示前綴異或和 那麼就是找l−1≤i&lt;j≤rl-1 \leq i &lt; j \leq rl−1≤i<j≤r且si xor sj=ks_i\ xor\ s_j=k

原创 2019南昌網絡賽D.Interesting Series

鏈接 點擊跳轉 題解 F(n)=1−an1−aF(n)=\frac{1-a^n}{1-a}F(n)=1−a1−an​ 構造生成函數 (1+as1x)(1+as2x)...(1+asnx)(1+a^{s_1}x)(1+a^{s_2}

原创 cf383C. Propagating tree

鏈接 點擊跳轉 題解 標記永久化,線段樹維護這個dfsdfsdfs序區間中深度爲奇數/偶數的點被加了幾 代碼 #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container

原创 cf438D. The Child and Sequence

鏈接 點擊跳轉 題解 一個數被取模如果數值有變化的話,那至少減少一半 那麼每個數就只能被修改logloglog次 那就可以線段樹維護最大值+暴力取模 複雜度是兩個logloglog 代碼 #include <bits/stdc++

原创 cf372C. Watching Fireworks is Fun

鏈接 點擊跳轉 題解 看完數據規模就覺得這題肯定卡logloglog dpijdp_{ij}dpij​表示放第iii個はなび時候我在第jjj個位置此時開心值的最大值 那麼dpij=bi−∣ai−j∣+max(dpi−1,k)dp_

原创 cf501D. Misha and Permutations Summation

鏈接 點擊跳轉 題解 ord(p)=a1(n−1)!+a2(n−2)!+...anord(p) = a_1(n-1)! + a_2(n-2)! + ... a_nord(p)=a1​(n−1)!+a2​(n−2)!+...an​