AcWing 5366. 大小写转换

签到题,可以用stl里面的tolower函数

#include <bits/stdc++.h>
#define ls p<<1
#define rs p<<1|1
#define PII pair<int, int>
#define ll long long
#define db double
#define ull unsigned long long
#define endl '\n'
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 2e5 + 10;
int t, n;
int a[N], sum[N], b[N]; void solve()
{
string a, b;
cin >> a;
for(int i = 0; i < a.size(); ++ i) a[i] = tolower(a[i]);
cout << a;
} int main()
{
io
// freopen("1.in", "r", stdin);
// cin >> t;
// while(t --)
solve();
return 0;
}

AcWing 5367. 不合群数

最大的不合群数明显是\([a + 1, b]\)内的最大质数,题目上还有提示相邻质数之间不超过300,我们到这枚举如果有质数,枚举300次就能找到。

#include <bits/stdc++.h>
#define ls p<<1
#define rs p<<1|1
#define PII pair<int, int>
#define ll long long
#define db double
#define ull unsigned long long
#define endl '\n'
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 2e5 + 10;
int t, n;
int a[N], sum[N], b[N], ans;
map<int, int>mp; void solve()
{
int a, b; cin >> a >> b;
for(int i = b; i > a; -- i)
{
bool success = true;
for(int j = 2; j <= a && j * j <= i; ++ j)
{
if(i % j == 0)
{
success = false;
break;
}
}
if(success)
{
cout << i << endl;
return;
}
}
cout << -1 << endl;
} int main()
{
io
// freopen("1.in", "r", stdin);
// cin >> t;
// while(t --)
solve();
return 0;
}

AcWing 5368. 最短距离

两问:

第一问:同类点之间的距离是否都为0

第二问:如果第一问回答是,求出不同类之间的距离

对于第一问显然,只有边权为0的边才有用,同类点之间的边权都为0他们之间的距离才为0,用并查集维护边权为0的点,最后检查如何两个点是同类他们之间的边权不为0说明距离不为0

第二问:我们记录类与类之间的最小边权,因为题目中说了可能有重边,然后跑一遍floyd就行了,跑floyd的时候需要注意一下初始化距离数组,自己到自己也就是d[i][i]=0

#include <bits/stdc++.h>
#define ls p<<1
#define rs p<<1|1
#define PII pair<int, int>
#define ll long long
#define db double
#define ull unsigned long long
#define endl '\n'
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3f3f3f3f
using namespace std;
const int N = 1e5 + 10;
int t, n, m, q;
int fa[N], d[510][510], id[N]; int find(int x)
{
if(x == fa[x]) return x;
return fa[x] = find(fa[x]);
} bool check()
{
for(int i = 2; i <= n; ++ i)
if(id[i] == id[i - 1] && find(i) != find(i - 1)) return false;
return true;
} void solve()
{
cin >> n >> m >> q;
for(int i = 1; i <= n; ++ i) fa[i] = i;
memset(d, 0x3f, sizeof(d));
for(int i = 1, j = 1; i <= q; ++ i)
{
int cnt; cin >> cnt;
while(cnt --) id[j ++] = i;
}
for(int i = 1; i <= m; ++ i)
{
int x, y, w; cin >> x >> y >> w;
if(!w) fa[find(x)] = find(y);
x = id[x], y = id[y];
d[y][x] = d[x][y] = min(d[x][y], w);
} if(!check())
{
cout << "No" << endl;
return;
} for(int k = 1; k <= q; ++ k)
for(int i = 1; i <= q; ++ i)
for(int j = 1; j <= q; ++ j)
{
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
if(i == j) d[i][j] = d[j][i] = 0;
} cout << "Yes" << endl;
for(int i = 1; i <= q; ++ i)
{
for(int j = 1; j <= q; ++ j)
{
int dist = d[i][j];
if(dist == INF) cout << -1 << ' ';
else cout << dist << ' '; }
cout << endl;
}
} int main()
{
io
// freopen("1.in", "r", stdin);
// cin >> t;
// while(t --)
solve();
return 0;
}

Acwing第132场周赛的更多相关文章

  1. AcWing第85场周赛

    这场周赛是手速局hh 死或生 某国正在以投票的方式决定 2 名死刑犯(编号 1∼2)的生死. 共有 n 组人员(编号 1∼n)参与投票,每组 10 人. 每组成员只参与一名死刑犯的投票,其中第 i 组 ...

  2. AcWing 第11场周赛题解

    计算abc 首先 \(0<=a<=b<=c\) 会随机给出 \(a+b,a+c,b+c,a+b+c\)的值 因为\(a,b,c\)都为正整数,所以\(a+b+c\)一定为最大值 然后 ...

  3. AcWing第78场周赛

    今天想起来了,就补一下吧~ 第一题 商品分类 货架中摆放着 n 件商品,每件商品都有两个属性:名称和产地. 当且仅当两件商品的名称和产地都相同时,两件商品才视为同一种商品. 请你统计,货架中一共有多少 ...

  4. LeetCode-第 166 场周赛

    LeetCode-第 166 场周赛 1281.subtract-the-product-and-sum-of-digits-of-an-integer 1282.group-the-people-g ...

  5. LeetCode 第 165 场周赛

    LeetCode 第 165 场周赛 5275. 找出井字棋的获胜者 5276. 不浪费原料的汉堡制作方案 5277. 统计全为 1 的正方形子矩阵 5278. 分割回文串 III C 暴力做的,只能 ...

  6. LeetCode--第180场周赛

    LeetCode--第180场周赛 1380. 矩阵中的幸运数 class Solution { public: vector<int> luckyNumbers (vector<v ...

  7. Leetcode第 217 场周赛(思维量比较大)

    Leetcode第 217 场周赛 比赛链接:点这里 做完前两题我就知道今天的竞赛我已经结束了 这场比赛思维量还是比较大的. 1673. 找出最具竞争力的子序列 题目 给你一个整数数组 nums 和一 ...

  8. 【AcWing】第 62 场周赛 【2022.07.30】

    AcWing 4500. 三个元素 题目描述 给定一个长度为 \(n\) 的数组 \(r\_1,r\_2,-,r\_n\). 请你找到其中的三个元素 \(r\_a,r\_b,r\_c\),使得 \(r ...

  9. Leetcode 第133场周赛解题报告

    今天参加了leetcode的周赛,算法比赛,要求速度比较快.有思路就立马启动,不会纠结是否有更好的方法或代码可读性.只要在算法复杂度数量级内,基本上是怎么实现快速就怎么来了. 比赛时先看的第二题,一看 ...

  10. 第二场周赛(递归递推个人Rank赛)——题解

    很高兴给大家出题,本次难度低于上一场,新生的六个题都可以直接裸递归式或者裸递推式解决,对于老生的汉诺塔3,需要找出一般式,后两题分别为裸ST算法(或线段树)/线性DP. 正确的难度顺序为 种花 角谷定 ...

随机推荐

  1. CreateProcess函数源码分析

    CreateProcess函数源码分析 ​ 源码版本:Windows 2003 源码 ​ 源码阅读工具:Source Insight 函数功能分析 函数原型 BOOL CreateProcessA( ...

  2. TienChin 活动管理-活动列表展示

    后端 ActivityVO /** * @author BNTang * @version 1.0 * @description 活动管理VO * @since 2023-23-05 **/ publ ...

  3. 中文多模态医学大模型智能分析X光片,实现影像诊断,完成医生问诊多轮对话

    中文多模态医学大模型智能分析X光片,实现影像诊断,完成医生问诊多轮对话 1.背景介绍介绍 最近,通用领域的大语言模型 (LLM),例如 ChatGPT,在遵循指令和产生类似人类响应方面取得了显著的成功 ...

  4. 【5】OpenCV2.4.9实现图像拼接与融合方法【SURF、SIFT、ORB、FAST、Harris角点 、stitch 】

    相关文章: [1]windows下安装OpenCV(4.3)+VS2017安装+opencv_contrib4.3.0配置 [2]Visual Studio 2017同时配置OpenCV2.4 以及O ...

  5. 4.1 C++ Boost 字符串处理库

    Boost 库是一个由C/C++语言的开发者创建并更新维护的开源类库,其提供了许多功能强大的程序库和工具,用于开发高质量.可移植.高效的C应用程序.Boost库可以作为标准C库的后备,通常被称为准标准 ...

  6. CF452F Permutation 与 P2757 [国家集训队] 等差子序列 题解

    两道基本一样的题: 题目链接: P2757 [国家集训队] 等差子序列 Permutation 链接:CF 或者 洛谷 等差子序列那题其实就是长度不小于 \(3\) 的等差数列是否存在,我们考虑等于 ...

  7. 开源.NetCore通用工具库Xmtool使用连载 - 发送短信篇

    [Github源码] <上一篇> 介绍了Xmtool工具库中的发送邮件类库,今天我们继续为大家介绍其中的发送短信类库. 发送短信就像发送邮件一样,在软件系统中使用非常普遍,甚至比发送邮件还 ...

  8. 统一日志输出打印POST请求参数

    众所周知,request.getInputStream()只能调一次.如果希望在请求进入Controller之前统一打印请求参数(拦截器或过滤器),又不影响业务,我们只能将获取到的输入流缓存起来,后续 ...

  9. String--cannot convert from 'const char *' to 'LPTSTR'错误

    这种错误,很多情况下是类型不匹配 LPTSTR表示为指向常量TCHAR字符串的长指针 TCHAR可以是wchar_t或char,基于项目是多字节还是宽字节版本. 看下面的代码,代码来源:Example ...

  10. win32-EnumChildWindows的使用

    #include <Windows.h> #include <iostream> #include <string> static BOOL CALLBACK en ...