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

推荐订阅源

Project Zero
Project Zero
GbyAI
GbyAI
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
小众软件
小众软件
The GitHub Blog
The GitHub Blog
阮一峰的网络日志
阮一峰的网络日志
J
Java Code Geeks
WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
IT之家
IT之家
F
Fortinet All Blogs
博客园 - 【当耐特】
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Proofpoint News Feed
Schneier on Security
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
Spread Privacy
Spread Privacy
O
OpenAI News
V
V2EX
博客园 - 三生石上(FineUI控件)
AI
AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
P
Privacy International News Feed
Microsoft Azure Blog
Microsoft Azure Blog
Blog — PlanetScale
Blog — PlanetScale
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
H
Help Net Security
L
LINUX DO - 最新话题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Tenable Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Cisco Talos Blog
Cisco Talos Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 叶小钗
V
Vulnerabilities – Threatpost
C
Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
酷 壳 – CoolShell
酷 壳 – CoolShell
Hacker News: Ask HN
Hacker News: Ask HN
S
Security @ Cisco Blogs
S
Securelist
T
The Blog of Author Tim Ferriss
Apple Machine Learning Research
Apple Machine Learning Research
美团技术团队
雷峰网
雷峰网
V2EX - 技术
V2EX - 技术

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) Codeforces Round 919 (Div. 2) 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 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 887 (Div. 2)
Shiroha · 2023-09-09 · via Shiroha白羽的博客

A. Desorting

大致题意

有一个非递减数列,每次可以选择一个下标 $i$,使得 $\forall i \in [1, i], a_i \rightarrow a_i + 1$,同时 $\forall i \in [i + 1, n], a_i \rightarrow a_i - 1$

问最少需要几次操作

思路

简单题,找到差一点最小的,和 $2$ 做向上取整的除法就行了

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void solve() {
int _;
cin >> _;
for (int ts = 0; ts < _; ++ts) {
int n, last, diff = INT_MAX;
cin >> n;
cin >> last;
for (int i = 0; i < n - 1; ++i) {
int tmp;
cin >> tmp;
diff = min(diff, tmp - last);
last = tmp;
}

cout << max(0, (diff + 2) / 2) << endl;
}
}

B. Fibonaccharsis

大致题意

有一个 $k$ 的长度的数组,已知 $a_k = n$,问这个数组满足斐波那契数列的种数有多少

思路

在长度较长的情况下,$k \le n$ 是显然的,那么就可以排除掉一些

然后暴力计算出,假定初项 $x, y$,计算 $n = ax + by$ 中的 $a, b$,然后在暴力遍历所有可能即可

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
void solve() {
int _;
cin >> _;
for (int ts = 0; ts < _; ++ts) {
int n, k;
cin >> n >> k;
if (k >= n && k > 10) {
cout << 0 << endl;
continue;
}

int x[3] = {0, 1, 0}, y[3] = {0, 0, 1};
for (int i = 2; i < k; ++i) {
x[0] = x[1];
x[1] = x[2];
y[0] = y[1];
y[1] = y[2];

x[2] = x[0] + x[1];
y[2] = y[0] + y[1];
}

int tx = x[2], ty = y[2], ans = 0;
for (int i = 0; i < n; ++i) {
if (tx * i > n) break;
if ((n - tx * i) % ty == 0 && (n - tx * i) / ty >= i) ans++;
}
cout << ans << endl;
}
}

C. Ntarsis’ Set

大致题意

有一个无限长的数组,然后每次报数然后去掉其中一部分,去掉的报数下标为给出的 $a$ 数组,总共进行 $k$ 轮,问最终剩下的第一个值是原来下标多少的

思路

模拟一下,假设 $a = [1, 5, 10]$,且 $k$ 无限大,那么可以得到

下标1234567891011121314151617181920
被去掉的报数111151515101510151015101

规律就是当只有一个值的时候,都是 1 的循环,然后两个值的时候变成两个值的循环,依次类推。

因为每次 1 就意味着一个新的开始,所以当 1 不能再覆盖的地方就是答案

AC code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#define int long long

void solve() {
int _;
cin >> _;
for (int ts = 0; ts < _; ++ts) {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];

int j = 0, x = 1;
while (k--) {
while (j < n && a[j] <= x + j) j++;
x += j;
}

cout << x << endl;
}
}

D. Imbalanced Arrays

大致题意

给出一个数组 $a$,长度为 $n$,构造一个数组 $b$,其长度为 $n$,使得满足如下条件

  • $\forall i \in [1, n], -n \leq b_i \leq n$
  • $\forall i \in [1, n], j \in [1, n], b_i + b_j \neq 0$
  • 对于 $i$,计算 $\forall j \in [1, n]$,满足 $b_i + b_j > 0$ 的数量恰好为 $a_i$

思路

我也不知道咋过的,只是冥冥之中写了这个构造方案,过了,但是实在没能证明出来我是怎么对的

为了满足第一条和第二条,定下一个简答的原则:$b$ 数组的每一项取 $abs$ 后,得到的新数组恰好是 $n$ 的排列,这样可以直接满足前两项了

而后根据 $a$ 的大小,从大到小排序后遍历,如果当前值和上一个值相同,那么就取上一个值 $-1$,否则再减去它们两个值的差值(因为中间这些跳过的值肯定是负数,这样恰好可以满足对应的整数部分的要求),直到试图给当前值赋值为非正整数时,停止即可

然后再根据 $a$ 的大小,从小到大排序后遍历,取出剩下没有给的值中最大的,将其变成负值后就是对应的值,同时验证一下是否准确,若不准确就是无解

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
void solve() {
int _;
cin >> _;
for (int ts = 0; ts < _; ++ts) {
int n;
cin >> n;
vector<int> data(n);
for (auto &item: data) cin >> item;
vector<int> ans(n);

vector<int> usePos;
set<int> notUse;
for (int i = 1; i <= n; ++i) notUse.insert(i);
vector<pair<int, int>> sorted(n);
for (int i = 0; i < n; ++i) sorted[i] = {data[i], i};
sort(sorted.begin(), sorted.end(), greater<>());
int cur = n, last = n;
for (auto &item: sorted) {
cur -= last - item.first;
if (cur <= 0) break;
ans[item.second] = cur;
notUse.erase(cur);
usePos.push_back(cur);
--cur;
last = item.first;
}
sort(usePos.begin(), usePos.end(), greater<>());
sort(sorted.begin(), sorted.end());
int i = 0;
bool flag = true;
for (auto iter = notUse.rbegin(); iter != notUse.rend(); ++iter) {
int cnt = int(upper_bound(usePos.begin(), usePos.end(), *iter, greater<>()) - usePos.begin());
if (cnt != sorted[i].first) {
flag = false;
break;
}
ans[sorted[i].second] = -*iter;
i++;
}
if (!flag) {
cout << "NO" << endl;
continue;
}

cout << "YES" << endl;
for (auto &item : ans) cout << item << ' ';
cout << endl;
}
}