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& ...
随机推荐
- CSV文件存储
CSV 文件存储 CSV,全称为 Comma-Separated Values,中文可以叫作逗号分隔值或字符分隔值,其文件以纯文本形式存储表格数据.该文件是一个字符序列,可以由任意数目的记录组成,记录 ...
- C# 语言在AGI 赛道上能做什么
自从2022年11月OpenAI正式对外发布ChatGPT依赖,AGI 这条赛道上就挤满了重量级的选手,各大头部公司纷纷下场布局.原本就在机器学习.深度学习领域占据No.1的Python语言更是继续稳 ...
- ecnuoj 5039 摇钱树
5039. 摇钱树 题目链接:5039. 摇钱树 感觉在赛中的时候,完全没有考虑分数规划这种做法.同时也没有想到怎么拆这两个交和并的式子.有点难受-- 当出现分数使其尽量大或者小,并且如果修改其中直接 ...
- AGC044C Strange Dance
在2020年A卷省选day2t2有类似操作trie的技巧. 题目链接 显然是建一棵三叉trie树,代表0/1/2 对这棵trie树,我们需要支持子树交换和全局加1 考虑第一个操作怎么做?直接打个懒标记 ...
- 记录liunx服务器和docker时区修改
记录服务器和docker时区修改 前言 我的博客是部署在docker里面的,然后我发现评论和留言的时间和北京时间是有差别的,相差8个小时,然后发现是因为容器中的时区设置与服务器是不一致的,所以需要设置 ...
- Android案例分享,基于瑞芯微RK3568国产平台!
开发环境说明 Windows开发环境:Windows7 64bit.Windows10 64bit 虚拟机:VMware15.5.5 AndroidSDK编译环境:Ubuntu18.04.4 64bi ...
- cf edu 133 D
题意 思路 根据题意,最开始可以想到一个二维的dp状态 用dp[i][j]表示跳了j次刚好到i的方案数 如果是跳了j次,那么这次应该要被k+j-1整除才行 那么这样状态转移就是 dp[i][j] = ...
- QCon 回顾 | Data Fabric:逻辑统一、物理分散
Data Fabric(数据编织),自 2019 年开始就在 Gartner 年度技术趋势榜单上安家,并在 2022 年被列为数据分析领域十大技术趋势之首,它究竟有哪些价值?又如何在企业落地? 在近日 ...
- 【数据集】Maple-IDS——网络安全恶意流量检测数据集
一.数据集介绍 Maple-IDS数据集是一个网络入侵检测评估数据集,旨在增强异常基础入侵检测系统(IDS)和入侵预防系统(IPS)的性能和可靠性.随着网络空间安全领域攻击的日益复杂化,拥有一个可靠和 ...
- oeasy教您玩转vim - 30 - # 屏位行号
屏位行号 回忆上节课内容 上次我们主要讲的翻页 :set scrolloff=2 控制上下留天留地 上下翻页(这个最常用) ctrl + f 向下一屏 ctrl + b 向上一屏 上下移屏一行 c ...