随笔分类 - 我的AC梦
摘要:1 class Solution { 2 public: 3 const double eps=1e-6; 4 int isok(vector<int>& cards) 5 { 6 vector<double>dp[4][4]; 7 for(int i=0;i<4;i++)dp[i][i].push
阅读全文
摘要:1 class Solution { 2 public: 3 vector<int> sumOfDistancesInTree(int n, vector<vector<int>>& edges) { 4 vector<int>G[n],sz(n),sum(n); 5 for(auto &p:edg
阅读全文
摘要:1 class Solution { 2 public: 3 typedef long long ll; 4 const int lim=1e6; 5 int dx[8]={-1,0,1,0},dy[8]={0,1,0,-1}; 6 bool isEscapePossible(vector<vect
阅读全文
摘要:1 class Solution { 2 public: 3 vector<string>ans; 4 bool isAdditiveNumber(string num) { 5 int n=num.size(); 6 function<int(int,int)>dfs=[&](int u,int
阅读全文
摘要:1 class Solution { 2 public: 3 vector<double> dicesProbability(int n) { 4 int dp[n+1][70]; 5 memset(dp,0,sizeof(dp)); 6 for(int i=1;i<=6;i++)dp[1][i]=
阅读全文
摘要:1 class Solution { 2 public: 3 int reversePairs(vector<int>& nums) { 4 int n=nums.size(); 5 int a[n+1]; 6 function<int(int,int)>merge=[&](int l,int r)
阅读全文
摘要:博弈论dp,记忆化搜索,从最开始的状态去搜; dp[mouse][cat][turn]表示当前mouse ,cat,turn三种状态下先手能获得的最优解,其中优先级赢>和>输; 1 class Solution { 2 public: 3 4 int catMouseGame(vector<vect
阅读全文
摘要:1 const int N=1e5+5; 2 class Solution { 3 public: 4 int ch[N][26]; 5 vector<string> findAllConcatenatedWordsInADict(vector<string>& words) { 6 unorder
阅读全文
摘要:P1601 A+B Problem(高精) 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=505; 4 int a[N],b[N],c[N]; 5 void get(string &s,int *p) 6 { 7 int
阅读全文
摘要:1610. 可见点的最大数目 1 class Solution { 2 public: 3 const double pi=M_PI; 4 double get_angel(int x1,int y1,int x2,int y2) 5 { 6 return atan(1.0*(y2-y1)/(x2-
阅读全文
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 int len; 4 int myheap[12]; 5 //堆排序每个子节点最多交换log次,所以堆排是nlogn; 6 void put(int x) 7 { 8 myheap[++len]=x
阅读全文
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 struct node{ 4 node *left,*right; 5 int val; 6 }; 7 void insert(node * &bt,int n) 8 { 9 10 if(bt) 1
阅读全文
摘要:ACWing 1133. 第二短路 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef pair<int,int> pii; 4 const int N=1e5+5; 5 int dis1[N],dis2[N],ans=INT_MAX
阅读全文
摘要:leetcode 144. 二叉树的前序遍历 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * Tr
阅读全文
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=105; 4 int dis[N][N]; 5 int val[N]; 6 int n; 7 int main() 8 { 9 memset(dis,0x3f,sizeof(
阅读全文
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=1e5+5; 4 /*int ph,pt;//head tail; 5 int myq[20];//ph==pt队列为空; 6 //当进行了pop操作Ph会前移,造成空间浪费
阅读全文
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 string t[100]; 4 int tot=0; 5 int to_num(string &s) 6 { 7 int x=0,f=1; 8 for(auto &p:s) 9 { 10 if(p
阅读全文
摘要:1 #include<bits/stdc++.h> 2 #define mytest 3 using namespace std; 4 const int N=1e5+5; 5 const int mod=1337; 6 int h[N];//h[i]表示key为i的开头节点编号 7 int tot
阅读全文
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 char st[33],top; 4 int change_ten(int d) 5 { 6 int x=0; 7 for(int i=1;i<=top;i++) 8 { 9 if(st[i]>='
阅读全文