2025.2.19——1500
1.2025.2.19——1500
2.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——14002025.2.19——1500
A 1500
B 1500
C 1500
D 1500
------------------------------------------------
-
思维/图论+位运算/思维+数学/思维+构造/思维
A
- 存在路径即在一个连通块。
- 加上必须加的边,删去必须要删去的边。并查集维护查询,考虑一下删边和加边的先后顺序。
B
- 位运算入手点当然是单独考虑每一位。发现三个数中在同一位中有1个/2个1才会有贡献。
- 注意区间范围。
C
- 分奇偶模拟下过程发现结论。
D
- 尝试0101进行构造。
- 再考虑奇偶和
关系,找通解。
------------------------代码------------------------
A
#include <bits/stdc++.h>
#define int long long
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
#define bugv(VEC) \
{ \
for (auto Vec : VEC) \
cout << Vec << ' '; \
cout << '\n'; \
}
void _();
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(10);
int T = 1;
cin >> T;
while (T--)
_();
return 0;
}
// 带权并查集
struct DSU
{
vector<int> p, vs, es; // 集合数 点数 边数 (对一个连通块而言)
DSU(int n1) // p[x]不一定为根节点 find(x)一定是根节点
{
int n = n1 + 2;
p.assign(n, 0);
vs.assign(n, 0);
es.assign(n, 0);
for (int i = 1; i <= n1; i++)
p[i] = i, vs[i] = 1, es[i] = 0;
}
int find(int x) // 找到根节点
{
if (p[x] == x)
return x;
int px = find(p[x]);
return p[x] = px;
}
bool same(int a, int b)
{
return find(a) == find(b);
}
void merge(int a, int b) // 合并集合
{
int pa = find(a);
int pb = find(b);
if (pa == pb) // pa pb 均为根节点 p[pa]==pa
{
es[pa]++; // 1个集合 边+1
return;
}
p[pb] = p[pa]; // 改变b的根节点
vs[pa] += vs[pb]; // 将b合并进a
es[pa] += es[pb] + 1; // 2个集合
}
int size(int a) // 集合内的元素的个数
{
return vs[find(a)];
}
};
// DSU(n);
void _()
{
int n, m1, m2;
cin >> n >> m1 >> m2;
DSU F(n), G(n);
vector<pair<int, int>> ef(m1), eg(m2);
for (auto &[x, y] : ef)
cin >> x >> y;
for (auto &[x, y] : eg)
{
cin >> x >> y;
G.merge(x, y);
}
int res = 0;
for (auto [x, y] : ef)
{
if (!G.same(x, y))
res++;
else
F.merge(x, y);
}
for (auto [x, y] : eg)
{
if (!F.same(x, y))
{
res++;
F.merge(x, y);
}
}
cout << res << '\n';
}
B
#include <bits/stdc++.h>
#define int long long
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
#define bugv(VEC) \
{ \
for (auto Vec : VEC) \
cout << Vec << ' '; \
cout << '\n'; \
}
void _();
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(10);
int T = 1;
cin >> T;
while (T--)
_();
return 0;
}
void _()
{
int l, r;
cin >> l >> r;
int a = 0, b = 0, c = 0;
int hi = 32;
for (;; hi--)
{
int r_bit = r >> hi & 1, l_bit = l >> hi & 1;
if (r_bit - l_bit)
break;
else if (l_bit)
{
a |= 1 << hi, b |= 1 << hi, c |= 1 << hi;
}
}
c |= 1 << hi;
b = c - 1;
a = b - 1 < l ? c + 1 : b - 1;
cout << a << ' ' << b << ' ' << c << '\n';
}
// void _()
// {
// int a, b, c;
// cin >> a >> b >> c;
// cout << (a ^ b) + (b ^ c) + (a ^ c) << '\n';
// }
C
#include <bits/stdc++.h>
#define int long long
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
#define bugv(VEC) \
{ \
for (auto Vec : VEC) \
cout << Vec << ' '; \
cout << '\n'; \
}
void _();
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(10);
int T = 1;
cin >> T;
while (T--)
_();
return 0;
}
void _()
{
int n, k;
cin >> n >> k;
int st = 1, cnt = 0;
int l = 1, r = n;
while (r - l + 1 >= k)
{
int mid = l + r >> 1;
if (r - l + 1 & 1)
{
cnt += st;
r = mid - 1;
}
else
r = mid;
st <<= 1;
}
// int res = (1 + n >> 1) * cnt;
// if (n % 2 == 0)
// res = (1 + n) * cnt >> 1;
int res = (1 + n) * cnt >> 1;
cout << res << '\n';
}
D
#include <bits/stdc++.h>
#define int long long
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
#define bugv(VEC) \
{ \
for (auto Vec : VEC) \
cout << Vec << ' '; \
cout << '\n'; \
}
void _();
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(10);
int T = 1;
cin >> T;
while (T--)
_();
return 0;
}
void _()
{
int n, x, y;
cin >> n >> x >> y;
vector<int> f(n + 1);
if (n & 1)
{
int ans = 0;
for (int i = 1; i <= n; i++)
{
if (i == x)
f[i] = 2;
else
{
f[i] = ans;
ans ^= 1;
}
}
}
else
{
int ans = 0;
for (int i = 1; i <= n; i++)
{
f[i] = ans;
ans ^= 1;
}
if (abs(x - y) % 2 == 0)
f[x] = 2;
}
for (int i = 1; i <= n; i++)
cout << f[i] << ' ';
cout << '\n';
}
// void _()
// {
// int n, x, y;
// cin >> n >> x >> y;
// vector<set<int>> a(n + 1, set<int>());
// for (int i = 1; i <= n; i++)
// {
// int l = i - 1, r = i + 1;
// if (!l)
// l = n;
// if (r > n)
// r = 1;
// a[i].insert(l);
// a[i].insert(r);
// }
// a[x].insert(y);
// a[y].insert(x);
// auto cal = [](set<int> s)
// {
// int st = 0;
// for (auto v : s)
// {
// if (v - st)
// return st;
// st++;
// }
// return st;
// };
// for (int i = 1; i <= n; i++)
// cout << cal(a[i]) << ' ';
// cout << '\n';
// }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!