惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
有赞技术团队
有赞技术团队
Simon Willison's Weblog
Simon Willison's Weblog
人人都是产品经理
人人都是产品经理
L
LINUX DO - 最新话题
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
A
Arctic Wolf
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
小众软件
小众软件
Jina AI
Jina AI
The Cloudflare Blog
P
Palo Alto Networks Blog
AWS News Blog
AWS News Blog
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
Know Your Adversary
Know Your Adversary
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
NISL@THU
NISL@THU
G
GRAHAM CLULEY
Project Zero
Project Zero
博客园_首页
博客园 - 三生石上(FineUI控件)
罗磊的独立博客
Spread Privacy
Spread Privacy
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
Latest news
Latest news
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
S
Securelist
V
Vulnerabilities – Threatpost
T
The Exploit Database - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
IT之家
IT之家
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Last Watchdog
The Last Watchdog
T
Tenable Blog
宝玉的分享
宝玉的分享
S
Secure Thoughts
P
Privacy & Cybersecurity Law Blog
量子位
大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Security Archives - TechRepublic
Security Archives - TechRepublic

Shiroha白羽的博客

Golang 踩坑 —— interface 为参数的时候传 nil 指针 Codeforces Round 925 (Div. 3) Codeforces Round 924 (Div. 2) Codeforces Round 923 (Div. 3) Codeforces Round 922 (Div. 2) Codeforces Round 921 (Div. 2) Educational Codeforces Round 161 (Rated for Div. 2) Codeforces Round 920 (Div. 3) Hello 2024 Good Bye 2023 Codeforces Round 918 (Div. 4) 个人备份的常用 macOS 清理命令 Codeforces Round 917 (Div. 2) Pinely Round 3 (Div. 1 + Div. 2) Educational Codeforces Round 160 (Rated for Div. 2) Codeforces Round 915 (Div. 2) Codeforces Round 914 (Div. 2) Codeforces Round 913 (Div. 3) Educational Codeforces Round 159 (Rated for Div. 2) Codeforces Round 912 (Div. 2) Codeforces Round 911 (Div. 2) CodeTON Round 7 (Div. 1 + Div. 2, Rated, Prizes!) Educational Codeforces Round 158 (Rated for Div. 2) Codeforces Round 910 (Div. 2) Codeforces Round 909 (Div. 3) Codeforces Round 908 (Div. 2) Educational Codeforces Round 157 (Rated for Div. 2) C++自定义的字面量 Codeforces Round 907 (Div. 2) Codeforces Round 916 (Div. 3) 关于 LRU map 的一些灵感 2023 杭州站 ICPC 现场赛 反复横跳的 Clang-Tidy(cert-dcl21-cpp) Codeforces Round 906 (Div. 2) 一段奇怪的 CPP 代码 Codeforces Round 905 (Div. 3) Codeforces Round 904 (Div. 2) Codeforces Round 903 (Div. 3) Educational Codeforces Round 156 (Rated for Div. 2) Codeforces Round 902 (Div. 2, based on COMPFEST 15 - Final Round) Codeforces Round 901 (Div. 2) Codeforces Round 900 (Div. 3) Codeforces Round 899 (Div. 2) Educational Codeforces Round#155 (Div. 2) Codeforces Round 898 (Div. 4) CodeTON Round 6 (Div. 2) Codeforces Round 897 (Div. 2) Codeforces Round 896 (Div. 2) Codeforces Round 887 (Div. 2) Codeforces Round 895 (Div. 3) 左值-右值-将亡值 blog.mauve.icu Pinely Round 2 (Div. 1 + Div. 2) Harbour.Space Scholarship Contest 2023-2024 (Div. 1 + Div. 2) Codeforces Round 894 (Div. 3) Codeforces Round 888 (Div. 3) Educational Codeforces Round#153 (Div. 2) Codeforces Round 893 (Div. 2) OTPAUTH,两步验证中的通用协议 Codeforces Round 892 (Div. 2) Codeforces Round 891 (Div. 3) Codeforces Round 890 (Div. 2) Educational Codeforces Round#152 (Div. 2) blog.mauve.icu Java Script 的 null 和 undefined 随想 记一次 SQL LEFT JOIN 没有得到预期结果的错误 Codeforces Round#789(Div. 2) GCC/G++ 预编译头性能优化 使用 Junit5 和 Mockito 实现 SpringBoot 的单元测试最优美的解决方案 centOS 防火墙 docker-compse 的问题 C++ 语言实现动态变化的线程池 Codeforces Round#744 (Div. 3) 计算机图形学 Windows 通过网络访问 WSL2 原生 JavaScript 实现图片裁剪 面试复习(计算机图形学) 面试复习(算法) Codeforces Round#706(Div. 2)-Let's Go Hiking 面试复习(Java) 面试复习(Git) 面试复习(Linux) 面试复习(数据库) 面试复习(计算机网络) 面试复习(操作系统) 面试复习(C++) Codeforces Round#699 (Div. 2) 清理 WSL2 的磁盘占用 Codeforces Round#697 (Div. 3) Windows 下的 NTFS 驱动器索引 BUG 计算机网络复习 记一次 Navicat 连接 MySQL 一直报认证错误(Access denied) 计算机网络实验复习 WSL1 使用 Docker 一直无法启动 我的ACM脚印 2020牛客暑期多校训练营(第三场)D-Points Construction Problem——构造 2020牛客暑期多校训练营(第三场)E-Two Matchings——复杂思维与简单dp 2020牛客暑期多校训练营(第二场)I-Interval——最大流转对偶图求最短路 Educational Codeforces Round 80 D. Minimax Problem——二分+二进制处理 Codeforces Round 606 E. Two Fairs——图论 Codeforces Round 612 (Div. 2) C. Garland——DP
Codeforces Round 919 (Div. 2)
Shiroha · 2024-03-16 · via Shiroha白羽的博客

A. Satisfying Constraints

大致题意

给出一堆条件,包括是否大于、小于且不等于某个值,问最终有几个值符合条件

思路

先记录最小的那个区间,然后再过滤掉不满足的,就行了

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void solve() {
int _;
cin >> _;
for (int tc = 0; tc < _; ++tc) {
int n;
cin >> n;
int l = 0, r = INT_MAX;
set<int> s;
for (int i = 0; i < n; ++i) {
int o, x;
cin >> o >> x;
if (o == 1) l = max(l, x);
else if (o == 2) r = min(r, x);
else s.insert(x);
}
int cnt = r - l + 1;
for (auto& v: s) if (v <= r && v >= l) --cnt;
cout << max(0, cnt) << endl;
}
}

B. Summation Game

大致题意

两个人博弈,一个人先移除最多 $k$ 个值,另外一个人将会把最多 $x$ 个值变成负数,问最终所有值加起来最大是多少

思路

显然,删除最大的最有利,所以枚举删除几个即可

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void solve() {
int _;
cin >> _;
for (int tc = 0; tc < _; ++tc) {
int n, k, x;
cin >> n >> k >> x;
vector<int> data(n);
for (auto& i: data) cin >> i;
sort(data.begin(), data.end(), greater<>());
int total = 0, fx = 0;
for (int i = 0; i < n; ++i) {
total += data[i];
fx += i < x ? data[i] : 0;
}
int cur = 0, ma = 0;
for (int l = 0, r = x; l < k; ++l, ++r) {
cur -= r < n ? 2 * data[r] : 0;
cur += data[l];
ma = max(ma, cur);
}
cout << total - fx - fx + ma << endl;
}
}

C. Partitioning the Array

大致题意

一个数组,对于每个值再找一个特殊值取模,将其拆成 $n$ 等分,得到的每一个等分的数组相同,问有几种拆法

思路

拆法必然是数组长度的因子,暴力枚举即可。因为一个树的因子一定不会很多

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
int gcd(const int a, const int b) {
return b == 0 ? a : gcd(b, a % b);
}
void solve() {
int _;
cin >> _;
for (int tc = 0; tc < _; ++tc) {
int n;
cin >> n;
vector<int> data(n);
for (auto& i: data) cin >> i;
auto check = [&](const int x) {
const int len = n / x;
int tmp = 0;
for (int i = 1; i < x; ++i)
for (int j = 0; j < len; ++j)
tmp = gcd(abs(data[i * len + j] - data[(i - 1) * len + j]), tmp);
return tmp != 1;
};
int ans = 0;
for (int i = 1; i * i <= n; ++i) {
if (n % i) continue;
ans += check(i);
if (i * i != n) ans += check(n / i);
}
cout << ans << endl;
}
}

D. Array Repetition

大致题意

开始有一个空的数组,有两种操作:

  • 往数组最后加一个元素 $x$
  • 把整个数组复制 $x$ 次

问最终的数组中,第 $i$ 位是什么

思路

最终的数值一定是第一个操作得到的,所以可以考虑不断递归逆向整个操作过程,看看目标位置最终是被哪一次加入元素带来的

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#define int long long
void solve() {
int _;
cin >> _;
for (int tc = 0; tc < _; ++tc) {
int n, q;
cin >> n >> q;
vector<pair<int, int>> data(n);
for (auto& [fst, snd]: data) cin >> fst >> snd;
map<int, list<int>> mp;
int maxK = 0;
for (int i = 0; i < q; ++i) {
int tmp;
cin >> tmp;
mp[tmp].push_back(i);
maxK = max(maxK, tmp);
}
int tot = 0, i = 0;
for (; i < n; ++i) {
if (data[i].first == 1) ++tot;
else {
if ((maxK + tot - 1) / tot <= 1 + data[i].second)
data[i].second = (maxK + tot - 1) / tot;
tot *= 1 + data[i].second;
}
if (tot >= maxK) break;
}
vector<int> ans(q);
for (; i >= 0; --i) {
if (data[i].first == 1) {
if (const auto iter = mp.find(tot); iter != mp.end())
for (const auto& v: iter->second) ans[v] = data[i].second;
mp.erase(tot);
--tot;
} else {
const int len = tot / (1 + data[i].second);
for (auto iter = mp.upper_bound(len); iter != mp.end(); ) {
list<int>& l = mp[(iter->first - 1) % len + 1];
l.splice(l.end(), iter->second);
auto nxtIter = iter;
++nxtIter;
mp.erase(iter);
iter = nxtIter;
}
tot = len;
}
}
for (int i = 0; i < q; ++i) cout << ans[i] << " \n"[i == q - 1];
}
}