原创 [ICPC2018南京站M] 迴文樹+exKMP

題意: 思路: 我們可以通過將s串倒轉過來與t串跑一遍exKMP,然後再遍歷一遍extend數組,在遍歷的過程中將倒過來的s串加入到迴文樹中,當前位置i上的答案實際上就是extend[i]乘上以i開始的迴文串個數,由於我們是倒過來添加的

原创 [藍橋杯] 國王的煩惱 並查集+思維

題面: 思路: 由於存在刪邊操作,正着來處理可能不太好寫,但正難則反,我們可以反向來思考這個問題,我們可以按天數從大到小排序,那麼刪邊操作 import java.io.OutputStream; import java.io.IOE

原创 [LeetCode]第162場周賽題解

第一題: 分別維護每行每列添加的總和,最後加起來統計即可。 class Solution { public int oddCells(int n, int m, int[][] indices) { int an

原创 [LeetCode] 第165場周賽題解

第一題: 按題意模擬。 public class Solution { public boolean check(int[][] map,int val) { for(int i=0;i<3;i++) { if(map[i]

原创 [LeetCode]第164場周賽題解

第一題 沒啥好說的,簽到題。 public class Solution { public int minTimeToVisitAllPoints(int[][] p) { int ans=0;

原创 [杭電多校] 2019第五場B 01Trie+貪心

題意:給定兩個等長數組a,b,你可以隨意排列他們,使得數組c字典序最小,其中c[i]=a[i] xor b[i]。 思路:題解的做法貌似很複雜,但在直接建兩棵01Trie,在01Trie上貪心的做法也能通過。 public class

原创 [LeetCode] 第158場周賽題解

第一題: public class Solution { public int balancedStringSplit(String s) { int ans=0; int[] buf=new i

原创 [LeetCode] 第160場周賽題解

第一題: 因爲該函數具有嚴格的單調性,所以可以二分,即枚舉x二分y,但數據範圍過小沒啥必要。 public class Solution { public List<List<Integer>> findSolution(Custom

原创 [LeetCode] 第167場周賽題解

第一次進第一頁QAQ,然而還是手慢,在第二題浪費了好久的時間。 第一題: public class Solution { public int getDecimalValue(ListNode head) {

原创 如何用C語言打印心形

原理很簡單主要用到了一個心形函數:       #include <stdio.h> #include <windows.h> int main() { float i,j,a; int index=0;

原创 考研去了,祝我好運!

目標CSU,幹就完了,奧利給!!!

原创 [codeforces920G] 容斥+二分

題意:求出與p互質並且大於x的第k個數 思路:首先我們可以求出p的所有質因子,可以根據a/b表示[1,a]中以b爲因子的數的個數,然後用這個通過容斥來求得[1,a]中與與p互質的數的個數,然後就可以愉快地二分了。 import java

原创 [LeetCode] 第159場周賽題解

第一題: 爲防止丟失精度用乘法代替除法。 public class Solution { public boolean checkStraightLine(int[][] c) { boolean flag=true;

原创 [codeforces718B] 線段樹+矩陣

題意: 思路: 顯然線段樹維護矩陣,其中區間加操作可轉換區間乘上轉移矩陣的x次方,不過需要注意這題可能有點卡常,注意一些小細節的常數。 import java.io.OutputStream; import java.io.IOExce

原创 [LeetCode]第163場周賽題解

第一題: 首先讓k%(n*m),再把二維數組轉換成一維,後面比較容易處理。 public class Solution { public List<List<Integer>> shiftGrid(int[][] g, int k)