2025.2.19——1500

server/2025/2/22 16:21:17/

2025.2.19——1500


A 1500

B 1500

C 1500

D 1500

------------------------------------------------

  • 思维/图论+位运算/思维+数学/思维+构造/思维


A

  1. 存在路径即在一个连通块。
  2. 加上必须加的边,删去必须要删去的边。并查集维护查询,考虑一下删边和加边的先后顺序。

B

  1. 位运算入手点当然是单独考虑每一位。发现三个数中在同一位中有1个/2个1才会有贡献。
  2. 注意区间范围。

C

  1. 分奇偶模拟下过程发现结论。

D

  1. 尝试0101进行构造。
  2. 再考虑奇偶和 x 、 y x、y xy 关系,找通解。

------------------------代码------------------------

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个集合 边+1return;}p[pb] = p[pa];        // 改变b的根节点vs[pa] += vs[pb];     // 将b合并进aes[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++;elseF.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;}elser = 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';
// }


http://www.ppmy.cn/server/169414.html

相关文章

如何通过Windows环境远程控制MusicGPT在线生成高质量AI音乐

文章目录 前言1. 本地部署2. 使用方法介绍3. 内网穿透工具下载安装4. 配置公网地址5. 配置固定公网地址 前言 在这个快节奏的时代&#xff0c;音乐不仅是心灵的慰藉&#xff0c;更是创意的源泉。试想一下&#xff0c;在忙碌的工作间隙或悠闲的周末午后&#xff0c;只需轻敲几行…

Redis数据库面试——数据结构类型知识

大家好&#xff0c;这里是Good Note&#xff0c;关注 公主号&#xff1a;Goodnote&#xff0c;专栏文章私信限时Free。本文详细介绍Redis 提供的5种基本数据结构类型和4种特殊类型&#xff0c;除此之外&#xff0c;还有8种底层数据结构&#xff0c;每种结构类型有其特点和适用场…

数字可调控开关电源设计(论文+源码)

1 设计要求 在本次数字可调控开关电源设计过程中&#xff0c;对关键参数设定如下&#xff1a; &#xff08;1&#xff09;输入电压&#xff1a;DC24-26V,输出电压&#xff1a;12-24&#xff08;可调&#xff09;&#xff1b; &#xff08;2&#xff09;输出电压误差&#xf…

Docker 多阶段构建:优化镜像大小

在 Docker 中&#xff0c;构建镜像时&#xff0c;我们通常会将应用及其所有依赖打包到镜像中。然而&#xff0c;随着时间的推移&#xff0c;镜像的大小会随着依赖项和构建工具的增加而变得越来越大&#xff0c;这不仅增加了存储成本&#xff0c;还会降低容器启动速度。多阶段构…

VMware新建虚拟机

看看自己的电脑是什么内核&#xff0c;有几个处理器 再分配给虚拟机 镜像文件需要自己安装下载地方https://mirrors.aliyun.com/centos/?spma2c6h.13651104.d-2001.8.3fb1320cuI1jeS 然后就出现了 然后开启虚拟机&#xff0c;等待 等待之后如下&#xff0c;选择语言 等待一段时…

【前端】如何安装配置WebStorm软件?

文章目录 前言一、前端开发工具WebStorm和VS Code对比二、官网下载三、安装1、开始安装2、选择安装路径3、安装选项4、选择开始菜单文件夹5、安装成功 四、启动WebStorm五、登录授权六、开始使用 前言 WebStorm 是一款由 JetBrains 公司开发的专业集成开发环境&#xff08;IDE…

【Scrapy】Scrapy教程2——工作原理

文章目录 数据流组件引擎Engine调度器Scheduler下载器Downloader爬虫Spiders项目管道Item Pipeline下载器中间件Downloader Middlewares爬虫中间件Spider Middlewares 在学习Scrapy前&#xff0c;我们需要先了解其架构和工作原理&#xff0c;这样才能很好的去使用Scrapy。 Scra…

Unity中NavMesh的使用 及其 导出给java服务端进行寻路

1.先添加 AI Navigation组件 2.Windows-->AI-->Navigation(Obsolete) 这样子就可以看到烘焙按钮 3.将物体标记为行走和不可行走 4.添加一个Plane和一些球体&#xff0c;并把需要形成NavMesh的物体选择为静态 // 因为只能烘焙静态的 之后可以看出烘焙后&#xff0c;看着被…