アイラちゃん在 zotero 里加装了 bionic 插件
效果是这样的,会稍微有所提升阅读速度,浏览器アイラちゃん也会在阅读长 blog 的时候启用插件辅助阅读
一般来说长文阅读アイラちゃん很容易丢失上下文信息或者不专注(包括中文),阅读很慢,这样会稍微快一些
アイラちゃん在 zotero 里加装了 bionic 插件
效果是这样的,会稍微有所提升阅读速度,浏览器アイラちゃん也会在阅读长 blog 的时候启用插件辅助阅读
一般来说长文阅读アイラちゃん很容易丢失上下文信息或者不专注(包括中文),阅读很慢,这样会稍微快一些
这样吗,有点意思
(确实感觉怪提神的
驻波回去也试试喵
今天的天气很舒服,所以上午偷懒了一个小时才起床
X:@Gameillust_AI
上午结束!说实话有些遗憾,因为刷 leetcode 解题的速度还是比较慢,需要进一步熟悉知识点 + 提升解题/写代码的速度。
每日一题是经典的贪心!
135. 分发糖果 (H)(2025.06.02)
class Solution {
public:
int candy(vector<int>& ratings) {
// Two times iteration.
vector<int> ans;
int count = 1;
ans.emplace_back(count++);
for(int i = 1; i < ratings.size(); i++) {
if(ratings[i] > ratings[i-1]) {
ans.emplace_back(count++);
}
else {
count = 1;
ans.emplace_back(count++);
}
}
#ifdef DEBUG
cout << ans.size() << ' ' << ratings.size() << '\n';
for(int i = 0; i < ans.size(); i++) {
cout << ans[i] << ' ';
}
cout << '\n';
#endif
count = 1;
for(int i = ratings.size() - 1; i > 0; i--) {
if(ratings[i-1] > ratings[i]) {
ans[i-1] = max(ans[i-1], ++count);
}
else {
count = 1;
ans[i-1] = max(ans[i-1], count);
}
}
#ifdef DEBUG
cout << ans.size() << ' ' << ratings.size() << '\n';
for(int i = 0; i < ans.size(); i++) {
cout << ans[i] << ' ';
}
cout << '\n';
#endif
return reduce(ans.begin(), ans.end());
}
};
func candy(ratings []int) int {
n := int(len(ratings))
ans := make([]int, n)
count := 1
ans[0] = count
count++
for i := 1; i < n; i++ {
if ratings[i-1] < ratings[i] {
ans[i] = count
count++
} else {
count = 1
ans[i] = count
count++
}
}
count = 1
for i := n - 1; i > 0; i-- {
if ratings[i-1] > ratings[i] {
count++
ans[i-1] = max(ans[i-1], count)
} else {
count = 1
}
}
var final int = 0
for i := 0; i < n; i++ {
final = final + ans[i]
}
return final
}
继续复习图论:这是图论中经典的拓扑排序,采用 Kahn 算法。
好麻烦的题目
class Solution {
public:
bool isPrintable(vector<vector<int>>& targetGrid) {
// The tuple has color -> (up, down, left, right).
unordered_map<int, tuple<int,int,int,int>> color_mat;
// Find the tuple mat from the graph.
for(int i = 0; i < targetGrid.size(); i++) {
for(int j = 0; j < targetGrid[i].size(); j++) {
int color = targetGrid[i][j];
if(color_mat.find(color) == color_mat.end()) {
color_mat[color] = make_tuple(INT_MAX / 2, 0, INT_MAX / 2, 0);
}
const auto & [up, down, left, right] = color_mat[color];
color_mat[color] = make_tuple(min(up, i), max(down, i), min(left, j), max(right, j));
}
}
// Search the matrix and find the topology order.
unordered_map<int, unordered_set<int>> graph;
unordered_map<int, int> inDegree;
for(const auto & ele: color_mat) {
const int & color = ele.first;
const auto & [up, down, left, right] = ele.second;
graph[color] = unordered_set<int>();
if(inDegree.find(color) == inDegree.end()) {
inDegree[color] = 0;
}
for(int i = up; i <= down; i++) {
for(int j = left; j <= right; j++) {
if(targetGrid[i][j] != color && graph[color].find(targetGrid[i][j]) == graph[color].end()) {
graph[color].insert(targetGrid[i][j]);
inDegree[targetGrid[i][j]]++;
}
}
}
}
int n = graph.size();
queue<int> q;
int count = 0;
for(const auto & ele: inDegree) {
if(ele.second == 0) {
q.emplace(ele.first);
}
}
while(!q.empty()) {
int cur = q.front();
q.pop();
count++;
for(const auto & adj: graph[cur]) {
if(--inDegree[adj] == 0) {
q.emplace(adj);
}
}
}
#ifdef DEBUG
for(const auto & element: color_mat) {
const auto & [u,d,l,r] = color_mat[element.first];
cout << element.first << ":(" << u << ',' << d << ',' << l << ',' << r << ")\n";
}
for(const auto & element: graph) {
cout << element.first << " -> (";
for(const auto & adj: element.second) {
cout << adj << ',';
}
cout << '\n';
}
for(const auto & element: inDegree) {
cout << element.first << ": " << element.second << '\n';
}
cout << count << ' ' << n << '\n';
#endif
return count == n;
}
};
下午要和同学做星期四上午的 pre,以及交换星期二的数据挖掘推荐系统的展示 demo。看来今天下午又无法读论文了…没有意义的大作业真的害人不浅,强烈抨击金课! 先去
啦~
自律
再不跑就生锈了
现在又下雨了完蛋了
好自律
对我来说 跑步一直是极度痛苦的事情
既不想上学也不想上班 我也想每天
想到将来还要至少上 20 年班我就不行了
我也不想当社畜
为什么才 20 年
三十五岁危机
2025 年 6 月 2 日 星期一 天气:小雨转阴
上午:
下午和晚上:和同学完成星期四 ppt 的制作,以及星期二 demo 的制作。但是没想到我的 baseline 数据竟然不见了!平台的监控数据只保存 14 天,所以今晚要赶紧取得数据补充好我们的 PPT。PPT 上涉及到了模型、算法改动后与 baseline 的对比,虽然效果好像都没有比 baseline 好,甚至比 baseline 差,但还是要展示出来,分析出来效果不好的原因。但是同学训练的 reward 版本很好。
晚上一直在处理数据和 PPT,一点也不想搞了,好累口牙~~~
希望能坚持自律~不然身体会垮掉的
明天又要上课了,不想上课,不想工作 只想快乐地
~
祝大家有美好的新的一周!晚安~
X: @ComikeMaster
坚持每日一题是我的 leetcode 账户名,所以就算今天上午 pre,我也要完成它!
(小声:其实做过了)
1298. 你能从盒子里获得的最大糖果数 (1825H)(2025.06.03)
class Solution {
public:
int maxCandies(vector<int>& status, vector<int>& candies, vector<vector<int>>& keys, vector<vector<int>>& containedBoxes, vector<int>& initialBoxes) {
// 2 times bfs. First get all the boxes final status. Second get the candies.
queue<int> q;
for(const auto & init: initialBoxes) {
q.emplace(init);
}
while(!q.empty()) {
int cur = q.front();
q.pop();
if(status[cur] == 1) {
for(const auto & key: keys[cur]) {
status[key] = 1;
}
}
for(const auto & adj: containedBoxes[cur]) {
q.emplace(adj);
}
}
// Then get the boxes candies.
int ans = 0;
for(const auto & init: initialBoxes) {
q.emplace(init);
}
while(!q.empty()) {
int cur = q.front();
q.pop();
if(status[cur] == 1) {
ans += candies[cur];
}
for(const auto & adj: containedBoxes[cur]) {
q.emplace(adj);
}
}
return ans;
}
};
下午先战数据库作业,然后准备后天 pre 的材料 + 再看看做好的复习笔记准备后天下午的考试!
祝自己一切顺利!
X: @kasuga_iz
感觉好像什么都在坏掉
今天感觉心脏有点难受,一个月前买的 pad 的充电线坏了,Mac 的充电线也坏了,type-C aux 转接线也坏了,跑步的鞋也开裂了,今早书包也坏了一个口子出来(看错了,书包是好的 )
只能重新买了吗,但是开销挺大的
那很坏了
战数据库事务处理
晚上再补齐 OCC( )和 MVCC
X:@haimiya_neno
为了简化调度方式,将数据库内的所有操作都看做仅有对特定资源的读取和写入操作。我们用 R_i(A) 表示第 i 个事务读取数据 A,W_i(A) 表示第 i 个事务写入数据 A。
冲突可序列 (confilict serializability)
视图可序列 (view serializability)
很显然冲突可序列化是比视图可序列化更严格 的。
为了保证得到正确的交叠操作调度,我们需要一些并发控制方法。
可执行判断 | 共享锁 | 排它锁 |
---|---|---|
共享锁 | ![]() |
![]() |
排它锁 | ![]() |
![]() |
简单的排它锁和共享锁无法保证可序列性。
阶段一:获得锁
阶段二:释放锁
一个调度是严格的当一个事务写入一份数据后,其他事务不能读取或覆盖这份数据,直到该事务终结。
可以看出严格程度:严格序列化 > 严格二阶段锁 > 冲突可序列化 > 视图可序列化
读操作
写操作
基础的时间戳操作保证了冲突可序列性质。
写操作处有所不同。
很明显仅保证视图可序列性。
2025 年 6 月 3 日 星期二 天气:多云
上午:
Demo,以及
下午和晚上:
不过没太看明白 MVCC,明天补上来 Note,再 copy 到 blog 上~
星期五又要组会,要炸了,アイラちゃん还没看完 reading list,明天一整天要加油看完
祝大家好梦~晚安 nya
X:@OuToTmeM
忙晕了,提前更一下日记楼~
2025 年 6 月 4 日 星期三 天气:多云
上午修改明天准备汇报的 ppt,评测结果出来了,强化学习对抗实在是太折磨人了,Level3 的胜率才 25%,不过 Level2 和 Level1 我们的胜率都是 100%。还是可以的吧。
其实做了很多的尝试,更换模型和算法,但是很显然这是不正确的。对抗性最重要的就是 reward 设计,前面的部分应该是在 reward 设计完了后再进行的工作。战略上的失误使得我们还是失去了一些优势。果然盲目的勤奋是没有办法掩盖战略上的懒惰的。这一点需要深思。
下午抽时间 leetcode 保持手感。
class Solution {
public:
string lastSubstring(string s) {
int i = 0, j = 1, n = s.size();
while (j < n) {
int k = 0;
while (j + k < n && s[i + k] == s[j + k]) {
k++;
}
if (j + k < n && s[i + k] < s[j + k]) {
int t = i;
i = j;
j = max(j + 1, t + k + 1);
} else {
j = j + k + 1;
}
}
return s.substr(i, n - i);
}
string answerString(string word, int numFriends) {
if(numFriends == 1) {
return word;
}
string last = lastSubstring(word);
int n = word.size(), m = last.size();
return last.substr(0, min(m, n - numFriends + 1));
}
};
#define DEBUG
#undef DEBUG
class Solution {
public:
string alienOrder(vector<string>& words) {
unordered_map<char, unordered_set<char>> graph;
unordered_map<char, int> inDegree;
bool flag = false;
auto add_edge = [&](const string & l, const string & r) -> void {
int i = 0;
for(i = 0; i < min(l.length(), r.length()); i++) {
if(graph.find(l[i]) == graph.end()) {
graph[l[i]] = unordered_set<char>();
}
if(inDegree.find(l[i]) == inDegree.end()) {
inDegree[l[i]] = 0;
}
if(l[i] != r[i] && graph[l[i]].find(r[i]) == graph[l[i]].end()) {
flag = true;
graph[l[i]].insert(r[i]);
inDegree[r[i]]++;
break;
}
else if(l[i] != r[i]) {
flag = true;
break;
}
}
if(!flag && l.length() > r.length()) {
return;
}
flag = true;
int temp = i;
for(; i < l.length(); i++) {
if(graph.find(l[i]) == graph.end()) {
graph[l[i]] = unordered_set<char>();
}
if(inDegree.find(l[i]) == inDegree.end()) {
inDegree[l[i]] = 0;
}
}
i = temp;
for(; i < r.length(); i++) {
if(graph.find(r[i]) == graph.end()) {
graph[r[i]] = unordered_set<char>();
}
if(inDegree.find(r[i]) == inDegree.end()) {
inDegree[r[i]] = 0;
}
}
};
// Step 1: Add edges.
if(words.size() == 1) {
flag = true;
for(int i = 0; i < words[0].length(); i++) {
if(graph.find(words[0][i]) == graph.end()) {
graph[words[0][i]] = unordered_set<char>();
}
if(inDegree.find(words[0][i]) == inDegree.end()) {
inDegree[words[0][i]] = 0;
}
}
}
else {
for(int i = 0; i < words.size(); i++) {
for(int j = i + 1; j < words.size(); j++) {
add_edge(words[i], words[j]);
}
}
}
#ifdef DEBUG
for(auto & elem: graph) {
cout << elem.first << ": ";
for(const auto & adj: elem.second) {
cout << adj << ' ';
}
cout << '\n';
}
for(auto & elem: inDegree) {
cout << elem.first << ": " << elem.second << "\n";
}
string flag_str = (flag == true) ? "true" : "false";
cout << flag_str << '\n';
#endif
// Step 2: TopoSort.
queue<char> q;
string ans;
for(const auto & ch: inDegree) {
if(ch.second == 0) {
q.emplace(ch.first);
}
}
while(!q.empty()) {
char ch = q.front();
ans.push_back(ch);
q.pop();
for(const auto & adj: graph[ch]) {
if(--inDegree[adj] == 0) {
q.emplace(adj);
}
}
}
return ans.length() == graph.size() && flag ? ans : "";
}
};
基于基环树的思想。
class Solution {
public:
int maximumInvitations(vector<int>& favorite) {
int n = favorite.size();
vector<vector<int>> reverse_graph(n);
queue<int> q;
vector<int> inDegree(n, 0);
for(int i = 0; i < n; i++) {
inDegree[favorite[i]]++;
}
for(int i = 0; i < n; i++) {
if(inDegree[i] == 0) {
q.emplace(i);
}
}
while(!q.empty()) {
int cur = q.front();
q.pop();
// Build reverse_graph;
reverse_graph[favorite[cur]].emplace_back(cur);
if(--inDegree[favorite[cur]] == 0) {
q.emplace(favorite[cur]);
}
}
// Dfs reverse graph find the shortest edge.
auto dfs = [&](this auto && dfs, int from) -> int {
int max_depth = 1;
for(const auto & adj: reverse_graph[from]) {
max_depth = max(max_depth, dfs(adj) + 1);
}
return max_depth;
};
// Find the cycle.
int ring = 0, chain = 0;
for(int i = 0; i < n; i++) {
if(inDegree[i] == 0) {
continue;
}
inDegree[i] = 0;
int tmp_ring = 1;
for(int adj = favorite[i]; adj != i; adj = favorite[adj]) {
inDegree[adj] = 0; // mark as visited.
tmp_ring++;
}
if(tmp_ring == 2) {
chain = chain + dfs(i) + dfs(favorite[i]);
} else {
ring = max(ring, tmp_ring);
}
}
return max(chain, ring);
}
};
然后焦虑/抑郁状态出现了,突然一下子什么都不想干,只能停下手中的学习任务去外面走一走
拍照的地方在兰香湖附近,是アイラちゃん心情不好的时候最常去的地方。只要在安静的地方发上半个小时的呆,好像什么都会变好的。有时候止不住地想,是不是我选择了错误的道路,选择了错误的人生,还是什么时候做了错误的事情呢,以至于现在进退两难,也不知道未来在哪里,为了尝试保研也没有认真的去找工作。如果,如果考研和保研都失败了,没有实习经验的アイラちゃん又应该怎样才能找到理想的工作呢,如果不找本专业的工作我又会什么呢。现在的アイラちゃん还不知道答案是什么,未来在何处。
今天晚上就是准备明天下午的考试了,希望能够一切顺利吧,明天上午的 pre,明天下午的考试。星期五的组会明天考完试再准备吧。
祝大家今晚好梦~
X: @ji10me
我也是
答案是并不会怎么样 你想太多了