2024.12.5 周四
1.2025.2.19——15002.11.23 周六3.11.24 周日4.11.25 周一日常5.2024.11.26 周二日常6.2024.11.27 周三7.2024.11.28周四8.2024.11.29 周五9.2024.11.30 周六10.2024.12.1 周日11.2024.12.2 周一12.2024.12.3 周二13.2024.12.4 周三
14.2024.12.5 周四
15.2024.12.7 周六16.2024.12.8 周日17.2024.12.9 周一18.2024.12.10 周二19.2024.12.11 周三20.2024.12.12 周四21.2024.12.13 周五22.2024.12.14 周六23.2024.12.16 周一24.2024.12.17 周二25.2024.12.18 周三26.2024.12.19 周四27.2024.12.20 周五28.2024.12.21 周六29.2024.12.22 周日30.2024.12.23 周一31.2024.12.24 周四32.2024.12.25 周三33.2024.12.26 周四34.2024.12.27 周五35.2024.12.28 周六36.2024.12.29 周日37.2024.12.30 周一38.2025.1.5——120039.2025.1.12——120040.2025.1.14——120041.2025.1.15——120042.2025.1.16——120043.2025.1.17——120044.2025.1.18——130045.2025.1.19——130046.2025.1.20——130047.2025.1.21——130048.2025.1.22——130049.2025.1.24——140050.2025.1.26——140051.2025.2.8——140052.2025.2.9——140053.2025.2.10——140054.2025.2.14——140055.2025.2.15——140056.2025.2.17——14002024.12.5 周四
Q1. 1000
给定x2~xn(<=500),构造a1~an,满足i:2~n,x[i]==a[i]%a[i-1]。
Q2. 1200
n户人家在一条线上,现在在某两户i,i+1之间/两端修建一条公路,给定一01串:0代表希望在公路左边,1则相反。
要求两侧都要有至少一半人家满意。多解则:i尽量距离中间人家最近,如仍多解则选取较小的i。
Q3. 1300
给定长度为n的数组a和空数组b。二人博弈:Alice选一ai放到b里;Bob选一ai扔掉。
问最优策略下MEX{a}的最大值。
Q4. 1400
给定n堆石子,二人博弈:每次选定k[1~石子数最少的堆的石子数量],然后将所有非空堆的石子数减少k颗。
最后无法操作者输,问最优策略下胜负。
------------------------独自思考分割线------------------------
-
这次也是比较顺利,除了被Q2卡了一下。确实做这样分段的题还是比较酣畅淋漓的,经过思考能够做出来,不会无效思考,正好锻炼下思维提高思维速度减少所用时间。等思维敏捷顺畅了,再冲高分段的。
A1.
1点:想到对于大数k加上小数b有(k+b)%k==b。
A2.
2点:1.通过前缀快速处理所有合法位置,再进行排序处理。细节搞了好长时间。
2.更妙的做法是可以处理的时候顺便更新答案。除法取整不如翻倍为乘法。
A3.
3点:1.首先应该意识到博弈论不能简单地考虑贪心,应该有个双方最优思维的模拟过程。
2.意识到答案可以二分。
3.最优思维的过程:对于个数大于1个数字无论Bob删除哪个Alice总可以拿到。
则检查x是否可以为答案时,只需要0~x-1数的个数无0,至多1个1即可为答案。
A4.
2点:1.意识到可以排序去重加差分,然后从前向后操作。
2.考虑转折点"攻守易势",即差分后的数组>1,模拟最优策略发现最先到转折点的将一直掌握主动权。
若前n-1个都是1则考虑奇偶性,否则考虑第一个转折点。
------------------------代码分割线------------------------
A1.
#include <bits/stdc++.h>
#define int long long //
#define endl '\n' // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(6);
int T = 1;
cin >> T;
while (T--)
_();
return 0;
}
void _()
{
int n;
cin >> n;
int res = 1e8;
cout << res << ' ';
for (int i = 2; i <= n; i++)
{
int x;
cin >> x;
res += x;
cout << res << ' ';
}
cout << endl;
}
A2.
#include <bits/stdc++.h>
#define int long long //
#define endl '\n' // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(6);
int T = 1;
cin >> T;
while (T--)
_();
return 0;
}
void _()
{
int n;
cin >> n;
string s;
cin >> s;
s = " " + s + " ";
vector<int> pre_l0(n + 2), pre_r1(n + 2);
for (int i = 1; i <= n; i++)
pre_l0[i] += pre_l0[i - 1] + (s[i] == '0');
for (int i = n; i; i--)
pre_r1[i] += pre_r1[i + 1] + (s[i] == '1');
int res = -1;
auto d = [&](int x)
{
return abs(n - x * 2);
};
for (int i = 0; i <= n; i++)
if (pre_l0[i] << 1 >= i && pre_r1[i + 1] << 1 >= n - i)
{
// bug(i);
if (d(i) < d(res))
res = i;
}
cout << res << endl;
}
A3.
#include <bits/stdc++.h>
#define int long long //
#define endl '\n' // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(6);
int T = 1;
cin >> T;
while (T--)
_();
return 0;
}
void _()
{
int n;
cin >> n;
map<int, int> cnt;
for (int i = 0; i < n; i++)
{
int x;
cin >> x;
cnt[x]++;
}
auto ok = [&](int x)
{
int f = 2;
for (int i = 0; i < x; i++)
if (cnt[i] == 1)
f--;
else if (!cnt[i])
f = 0;
return f > 0;
};
int l = 0, r = n + 10;
while (r - l - 1)
{
int mid = l + r >> 1;
if (ok(mid))
l = mid;
else
r = mid;
}
cout << l << endl;
}
// void _()
// {
// int n;
// cin >> n;
// map<int, int> cnt;
// for (int i = 0; i < n; i++)
// {
// int x;
// cin >> x;
// cnt[x]++;
// }
// for (int i = 0;; i++)
// if (cnt[i] < i + 1)
// {
// cout << i << endl;
// return;
// }
// }
A4.
#include <bits/stdc++.h>
#define int long long //
#define endl '\n' // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(6);
int T = 1;
cin >> T;
while (T--)
_();
return 0;
}
void _()
{
int n;
cin >> n;
vector<int> a(n);
for (int &x : a)
cin >> x;
sort(a.begin(), a.end());
a.erase(unique(a.begin(), a.end()), a.end());
for (int i = a.size() - 1; i >= 1; i--)
a[i] -= a[i - 1];
int fir = -1;
for (int i = 0; i < a.size(); i++)
if (a[i] - 1)
{
fir = i + 1;
break;
}
int f = 1;
if (fir + 1 && fir % 2 == 0)
f = 0;
if (fir == -1 && a.size() % 2 == 0)
f = 0;
cout << (f ? "Alice" : "Bob") << endl;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!