2023 ICPC网络赛第一场(A,D,J,L)
2023 ICPC网络赛第一场(A,D,J,L)
A Qualifiers Ranking Rules
先把两场比赛的学校排名处理出来,然后两场比赛的同位次进行合并即可
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<string> str1, str2,ans;
map<string, bool> vis1, vis2, vis;
string s;
for (int i = 0; i < n; i ++) {
cin >> s;
if (vis1[s]) continue;
str1.emplace_back(s);
vis1[s] = true;
}
for (int i = 0; i < m; i ++) {
cin >> s;
if (vis2[s]) continue;
str2.emplace_back(s);
vis2[s] = true;
}
n = str1.size(), m = str2.size();
for (int i = 0; i < max(n,m); i ++) {
if (i < n && !vis[str1[i]]) {
ans.emplace_back(str1[i]);
vis[str1[i]] = true;
}
if (i < m && !vis[str2[i]]) {
ans.emplace_back(str2[i]);
vis[str2[i]] = true;
}
}
for (auto i : ans)
cout << i << '\n';
return 0;
}
D Transitivity
如果题目给的所有的团都是完全图,那么就要合并两个最小的团,答案就是这两个团的点数的乘积,否则就要把所有的团都补成完全图,bfs或者并查集即可
#include <bits/stdc++.h>
#define debug(a) cout<<#a<<"="<<a<<'\n';
using namespace std;
using i64 = long long;
typedef pair<i64, i64> PII;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector g(n + 1, vector<int>());
for (int i = 0, x, y; i < m; i ++) {
cin >> x >> y;
g[x].push_back(y);
g[y].push_back(x);
}
vector<bool> vis(n + 1);
vector<i64> ans;
auto bfs = [&](int i) -> pair<i64, i64> {
queue<int> Q;
Q.push(i);
int edge = 0, node = 0;
while (Q.size()) {
auto v = Q.front();
Q.pop();
if(vis[v]) continue;
vis[v] = true;
node ++;
for (auto i : g[v]) {
if (vis[i]) continue;
Q.push(i);
edge ++;
}
}
return {node, edge};
};
bool is_Tuan = true;
i64 res = 0;
for (int i = 1; i <= n; i ++) {
if (vis[i]) continue;
auto [num, Edge] = bfs(i);
if (Edge != num * (num - 1) / 2) {
is_Tuan = false;
res += num * (num - 1) / 2 - Edge;
}
ans.push_back(num);
}
if (!is_Tuan) {
cout << res << '\n';
} else {
sort(ans.begin(), ans.end());
cout << ans[0] * ans[1] << '\n';
}
return 0;
}
J Minimum Manhattan Distance
题意是求在\(C_2\)上取一点到\(C_1\)任意一点的最小期望曼哈顿距离.
由于题目要求是最小期望曼哈顿距离,所以可以等价于看做就到\(C_1\)圆心,为了方便计算,可以把\(C_2\)的圆心看成坐标轴原点,\(C_1\)的圆心通过对称变换到第一象限,设\(\{x_0,y_0\}\)为答案点,则有\(\begin{cases} x_0 = x_2 + r_2\cos\theta \\ y_0 = y_2+r_2\sin \theta\end{cases}\),答案为\(|x_1-x_0|+|y_1-y_0|\),
且题目规定\(\forall x_i \in C_1 \neq \forall x_j \in C_2,\forall y_i \in C_1 \neq \forall y_j\in C_2,\),所以当\(C_1\)在第一象限时,总有\(x_1>x_0,y_1>y_0\),所以绝对值可拆,然后用三角函数计算一下,可得出当\(\theta = \frac{\pi}{4}\)时有最小值\(x+y-\sqrt{2}\times r_2\).

#include<bits/stdc++.h>
using i64 = long long;
using namespace std;
typedef pair<i64, i64> PII;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
auto get = [&](double x1,double y1,double x2,double y2){
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
};
int T;
cin >> T;
while(T--){
double xa,ya,xb,yb,xc,yc,xd,yd;
cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd;
double r2 = get(xc,yc,xd,yd) / 2;
double x1 = (xa + xb) / 2, y1 = (ya + yb) / 2;
double x2 = (xc + xd) / 2, y2 = (yc + yd) / 2;
double ans = fabs(x1 - x2) + fabs(y1 - y2) - r2 * sqrt(2) ;
printf("%.10lf\n",ans);
}
return 0;
}
L KaChang!
签到题,题目规定了\(k\geq 2\),所以答案为\(\max(2,\lceil\frac{T}{\max\limits_{i=1}^{n}a_i}\rceil)\)
#include <bits/stdc++.h>
#define debug(a) cout<<#a<<"="<<a<<'\n';
using namespace std;
using i64 = long long;
typedef pair<i64, i64> PII;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
i64 n, k;
cin >> n >> k;
i64 ma = 0, x;
for(int i = 0;i < n;i ++){
cin >> x;
ma = max(ma, x);
}
cout << max(2ll, (k + ma - 1) / k) << '\n';
return 0;
}
2023 ICPC网络赛第一场(A,D,J,L)的更多相关文章
- 2021ICPC网络赛第一场部分题解-The 2021 ICPC Asia Regionals Online Contest (I)
写在前面 本来应该6题的,结果不知道哪个铸币发了H的clar,当即把我们的思路转向三维几何上.当时我们还在想这三维计算几何的正确率有点太高了还在感叹ICPC选手的含金量,直到赛后我才知道这H题的铸币出 ...
- Contest1585 - 2018-2019赛季多校联合新生训练赛第一场(部分题解)
Contest1585 - 2018-2019赛季多校联合新生训练赛第一场 C 10187 查找特定的合数 D 10188 传话游戏 H 10192 扫雷游戏 C 传送门 题干: 题目描述 自然数中除 ...
- NOI.AC NOIP模拟赛 第一场 补记
NOI.AC NOIP模拟赛 第一场 补记 candy 题目大意: 有两个超市,每个超市有\(n(n\le10^5)\)个糖,每个糖\(W\)元.每颗糖有一个愉悦度,其中,第一家商店中的第\(i\)颗 ...
- HDU6578 2019HDU多校训练赛第一场 1001 (dp)
HDU6578 2019HDU多校训练赛第一场 1001 (dp) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6578 题意: 你有n个空需要去填,有 ...
- HDU6579 2019HDU多校训练赛第一场1002 (线性基)
HDU6579 2019HDU多校训练赛第一场1002 (线性基) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6579 题意: 两种操作 1.在序列末 ...
- 2020ICPC·小米 网络选拔赛第一场
2020ICPC·小米 网络选拔赛第一场 C-Smart Browser #include <string> #include <iostream> std::string s ...
- Ryuji doesn't want to study 2018徐州icpc网络赛 树状数组
Ryuji is not a good student, and he doesn't want to study. But there are n books he should learn, ea ...
- 【2018ACM/ICPC网络赛】沈阳赛区
这次网络赛没有打.生病了去医院了..尴尬.晚上回来才看了题补简单题. K Supreme Number 题目链接:https://nanti.jisuanke.com/t/31452 题意:输入一个 ...
- 2015 多校赛 第一场 1001 (hdu 5288)
Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l&l ...
- contesthunter暑假NOIP模拟赛第一场题解
contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...
随机推荐
- Tarjan 求有向图的强连通分量
重温Tarjan, 网上看了许多博客感觉都讲的不清楚. 故传上来自己的笔记, 希望帮到大家. 提到的一些概念可以参考 oi wiki, 代码也是 oi wiki 的, 因为我不认为我能写出比大佬更好的 ...
- GIS数据获取:气象数据免费下载网站
本文对目前主要的气象数据获取网站加以整理与介绍. 本文为"GIS数据获取整理"专栏中第二篇独立博客,因此本文全部标题均由"2"开头.本文对目前主要的气象 ...
- Django设置、使用Cookie
使用背景: 前端根据用户选择的模块,结合ajax实现局部刷新,进到到具体模块页面后,返回,希望保持到原来选择的模块上,这就需要保存当前选择的模块id; 尝试: 1.使用Js的设置cookie,douc ...
- mysql的varchar和oracle的varchar2比较
首先说结论: 1.mysql存储的是字符数(不分语言) 2.oracle存储的需要看定义,如果定义为varchar2(n),则默认是n个字节,如果是varchar2(n char)则是n个字节. 3. ...
- 算法金 | A - Z,115 个数据科学 机器学习 江湖黑话(全面)
大侠幸会,在下全网同名「算法金」 0 基础转 AI 上岸,多个算法赛 Top 「日更万日,让更多人享受智能乐趣」 机器学习本质上和数据科学一样都是依赖概率统计,今天整整那些听起来让人头大的机器学习江湖 ...
- WAV音频文件按秒切片段
wav音频文件按秒切片段 import wave def split_wav_by_seconds(input_file, output_file, start_second, end_second) ...
- .NET 个人博客-给图片添加水印
个人博客-给图片添加水印 前言 需要用到的库 SixLabors.lmageSharp 2.1.3 SixLabors.lmageSharp.Web 2.0.2 SixLabors.Fonts 1.0 ...
- Profinet IO从站数据 转EtherCAT项目案例
目录 1 案例说明 1 2 VFBOX网关工作原理 1 3 准备工作 2 4 使用PRONETA软件获取PROFINET IO从站的配置信息 2 5 设置网关采集PROFINETIO从站设备数据 5 ...
- 记一次 .NET某网络边缘计算系统 卡死分析
一:背景 1. 讲故事 早就听说过有什么 网络边缘计算,这次还真给遇到了,有点意思,问了下 chatgpt 这是干嘛的 ? 网络边缘计算是一种计算模型,它将计算能力和数据存储位置从传统的集中式数据中心 ...
- PowerBuilder现代编程方法X11:PB程序完全跨平台方案
PB可能要支持Windows.macOS.Linux.iOS.Android与鸿蒙操作系统和X86.ARM.RISC-V与国产龙芯CPU的原生应用了! PowerBuilder现代编程方法X11:PB ...