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& ...
随机推荐
- 洛谷 P4343 自动刷题机
题目链接:自动刷题机 思路 二分典题,两个二分判断出可能的最大值和最小值.需要注意当删掉y行代码后,当前代码行数小于0时需要将代码行数重新赋值为0,然后需要注意二分的n最大值的边界,因为x[i]的最大 ...
- firewall-cmd设置NAT转换
配置ipv4转发 修改servera配置文件/etc/sysctl.conf ,修改参数为1 net.ipv4.ip_forward = 1 配置生效: sysctl -p 修改网卡的zone [ro ...
- .NET下 支持大小写不敏感的JSON Schema验证方法
问题 有很多应用程序在验证JSON数据的时候用到了JSON Schema. 在微服务架构下,有时候各个微服务由于各种历史原因,它们所生成的数据对JSON Object属性名的大小写规则可能并不统一,它 ...
- 嵌入式进阶之关于SPI通信的案例分享——基于全志科技T3与Xilinx Spartan-6处理器
本文主要介绍基于全志科技T3与Xilinx Spartan-6的通信案例. 适用开发环境: Windows开发环境:Windows 7 64bit.Windows 10 64bit Linux开发环境 ...
- rust项目中通过log4rs将日志写入文件
java项目中使用最广泛的日志系统应该是log4j(2)了.如果你也是一个Java程序员,可能在写rust的时候会想怎么能顺手地平移日志编写习惯到rust中来. log4rs就是干这个的.从名字就能看 ...
- Swift开发基础01-语法
Hello World print("Hello World") 不用编写main函数,Swift将全局范围内的首句可执行代码作为程序入口一句代码尾部可以省略分号(;),多句代码写 ...
- PHP中的__autoload()和spl_autoload_register()
php的__autoload函数是一个魔术函数,在这个函数出现之前,如果一个php文件里引用了100个对象,那么这个文件就需要使用include或require引进100个类文件,这将导致该php文件 ...
- 数据分析应该掌握的知识及SQL技能
一.概念及常识 1.数据分析必备的统计学知识 描述统计学 1.平均值.中位数.众数 2.方差.标准差 3.统计分布:正态分布.指数分布.二项分布.卡方分布 推论统计学 1.假设检验 2.置信区间 3. ...
- vue项目锚点定位+滚动定位
功能: HTML: js: scrollEvent(e) { let scrollItems = document.querySelectorAll('.condition-container') f ...
- P9058 [Ynoi2004] rpmtdq 与 P9678 [ICPC2022 Jinan R] Tree Distance
思路: 注意到点对数量有 \(N^2\) 个,考虑丢掉一些无用的点对. 对于点对 \((x_1,y_1),(x_2,y_2)\),满足 \(x_1 \le x_2 < y_2 \le y_1\) ...