上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 19 下一页
摘要: 注意到题目要求输出链表的节点个数,说明输入的节点中存在无效数据 特判:空链表 👉 code 阅读全文
posted @ 2020-08-04 12:55 Hellofds 阅读(57) 评论(0) 推荐(0)
摘要: **注意到$N(\leq 10^5)$,\(M(\leq 100)\),**那么对于数据集可以进行如下处理: 按题目要求对所有数据排序。 建立标记数组c[AGE],在$c_i$中记录年龄为$i$的人数,其中const int AGE = 205。再建立新数组s[N],记录有效数据。 遍历已有序的数据 阅读全文
posted @ 2020-08-03 10:52 Hellofds 阅读(55) 评论(0) 推荐(0)
摘要: dp动态规划 $dp[i][j]$表示$s[i] \to s[j]$是否对称,是为$1$,否为$0$ 状态转移方程:\(dp[i][j] = dp[i+1][j-1] \&\& (s[i]==s[j])\) 边界条件:\(dp[i][i]=1,dp[i][i+1]=(s[i]==s[i+1])\) 阅读全文
posted @ 2020-08-02 09:28 Hellofds 阅读(95) 评论(0) 推荐(0)
摘要: 这道题主要是解决超时问题 使用unordered_map代替map 参考: std::unordered_map map与unordered_map map和unordered_map的差别和使用 在PAT里使用map还是unordered_map? 使用unordered_map<string, 阅读全文
posted @ 2020-08-01 20:59 Hellofds 阅读(74) 评论(0) 推荐(0)
摘要: 题目的要求即为:对任意两个数字,确定它们的排序,使得两个数字串起来后得到的新数字最小 struct cmp { bool operator() (const int a, const int b) { char str[2][2*M]; strcpy(str[0], num[a]); strcat( 阅读全文
posted @ 2020-08-01 19:45 Hellofds 阅读(67) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 19 下一页