SMU 2024 spring 天梯赛自主训练3

7-1 2018我们要赢 - SMU 2024 spring 天梯赛自主训练3 (pintia.cn)

2018
wo3 men2 yao4 ying2 !

7-2 打折 - SMU 2024 spring 天梯赛自主训练3 (pintia.cn)

#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,r;
cin >> n >> r;
printf("%.2lf\n", n * (r) * 0.1); return 0;
}

7-3 电子汪 - SMU 2024 spring 天梯赛自主训练3 (pintia.cn)

#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 a,b;
cin >> a >> b;
for(int i = 0;i < a+ b;i ++)
cout << "Wang!"; return 0;
}

7-4 谁是赢家 - SMU 2024 spring 天梯赛自主训练3 (pintia.cn)

#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 pa, pb,a=0,b=0;
cin >> pa >> pb;
for(int i = 0;i < 3;i ++){
int x;
cin >> x;
a += (x == 0);
b += (x == 1);
} if(a + pa > b + pb && b != 3) {
printf("The winner is a: %d + %d\n",pa,a);
}else{
printf("The winner is b: %d + %d\n",pb,b);
} return 0;
}

7-5 福到了 - SMU 2024 spring 天梯赛自主训练3 (pintia.cn)

#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); char c;
int n;
cin >> c >> n;
vector<string> s(n), ans(n);
getline(cin, s[0]);
for (int i = 0; i < n; i ++) {
getline(cin , s[i]);
ans[i] = s[i];
reverse(ans[i].begin(), ans[i].end());
} reverse(ans.begin(), ans.end());
if (ans == s) {
cout << "bu yong dao le\n";
}
for (auto str : ans) {
for (auto i : str)
if (i != ' ') cout << c;
else cout << ' ';
cout << '\n';
} return 0;
}

7-6 倒数第N个字符串 - SMU 2024 spring 天梯赛自主训练3 (pintia.cn)

#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 L, n;
cin >> L >> n; string s = string(L, 'z');
for (int i = 1; i < n; i ++) {
int cnt = L - 1;
s[cnt]--;
while (s[cnt] < 'a' && cnt >= 0) {
s[cnt] = 'z';
s[--cnt] --;
}
} cout << s << '\n'; return 0;
}

7-7 天梯赛座位分配 - SMU 2024 spring 天梯赛自主训练3 (pintia.cn)

#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, sum = 0, m;
cin >> n, m = n;
vector<int> a(n + 1), now(n + 1);
for (int i = 1; i <= n; i ++) {
cin >> a[i];
a[i] *= 10;
sum += a[i];
} vector ans(n + 1, vector<int>());
int people = 0, val = 1;
while (sum--) {
for (int i = 1; i <= n; i ++) {
if (ans[i].size() < a[i]) {
ans[i].push_back(val);
if (people + 1 == n) val += 2;
else val ++;
people = 0;
for (int j = 1; j <= n; j ++)
if (ans[j].size() >= a[j])
people ++;
}
}
} for (int i = 1; i <= n; i ++) {
cout << '#' << i << '\n';
int cnt = 1;
for (int j = 0; j < ans[i].size(); j ++) {
cout << ans[i][j] << " \n"[cnt % 10 == 0];
cnt ++;
}
} return 0;
}

7-8 7206 猜数字 - SMU 2024 spring 天梯赛自主训练3 (pintia.cn)

直接从\(1000 \sim 9999\)枚举符合n个要求的数,如果只有一个说明答案唯一,否则就不能确定;

#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; auto check = [](int x, array<int, 3> Case) {
vector<int> NumX(5), NumC(5);
for (int i = 4; i >= 1; i --) {
NumX[i] = x % 10, x /= 10;
NumC[i] = Case[0] % 10, Case[0] /= 10;
} int SameNum = 0, SameLoc = 0;
for (int i = 1; i <= 4; i ++)
if (NumC[i] == NumX[i]) SameLoc ++;
for (int i = 1; i <= 4; i ++)
for (int j = 1; j <= 4; j ++)
if (NumC[j] == NumX[i]) {
SameNum ++, NumC[j] = -1;
break;
}
return (SameLoc == Case[2] && SameNum == Case[1]);
}; while (cin >> n) {
if (!n) break;
vector<array<int, 3>> Case(n);
for (auto &[a, b, c] : Case)
cin >> a >> b >> c;
int Ke = 0, ans = 0;
for (int i = 1000; i < 10000; i ++) {
int m = 0;
for (auto v : Case)
if (check(i, v)) m ++;
if (m == n) Ke ++, ans = i;
} if (Ke == 1) cout << ans << '\n';
else cout << "Not sure\n";
} return 0;
}

7-9 分而治之 - SMU 2024 spring 天梯赛自主训练3 (pintia.cn)

并查集;

考虑将攻打的城市除去外其余点是否都不能连通;

#include <bits/stdc++.h>
#define debug(a) cout<<#a<<"="<<a<<'\n'; using namespace std;
using i64 = long long; typedef pair<i64, i64> PII; struct UFS {
int n;
vector<int> fa; UFS(int n): n(n) {
fa.resize(n + 1);
for (int i = 0; i <= n; i ++)
fa[i] = i;
} int find(int x) {
return fa[x] == x ? x : find(fa[x]);
} void unin(int x, int y) {
x = find(x), y = find(y);
if (x != y) {
fa[x] = y;
}
}
}; int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); int n, m;
cin >> n >> m;
vector<PII> edge(m + 1);
for (int i = 1; i <= m; i ++) {
int u, v;
cin >> u >> v;
edge[i] = {u, v};
} int k;
cin >> k;
while (k --) {
int ke ;
cin >> ke;
set<int> cuit;
for (int i = 0; i < ke; i ++) {
int x;
cin >> x;
cuit.insert(x);
} UFS ufs(n);
for (auto [u, v] : edge) {
if (cuit.count(u) || cuit.count(v)) continue;
ufs.unin(u, v);
} int num = 0;
for (int i = 1; i <= n; i ++) {
if (ufs.find(i) == i) num ++;
} if (num == n) cout << "YES\n";
else cout << "NO\n";
} return 0;
}

7-10 小字辈 - SMU 2024 spring 天梯赛自主训练3 (pintia.cn)

dfs找到最大辈分并更新每个人的辈分;

#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;
cin >> n;
vector<int> fa(n + 1), Bei(n + 1);
int root = 0, mx = 0;
vector g(n + 1, vector<int>());
for (int i = 1; i <= n; i ++) {
cin >> fa[i];
if (fa[i] == -1) root = i;
else {
g[fa[i]].push_back(i);
}
} auto dfs = [&](auto dfs, int x) -> void{
Bei[x] ++;
for (auto v : g[x]) {
Bei[v] += Bei[x];
dfs(dfs, v);
}
}; dfs(dfs, root); for (int i = 1; i <= n; i ++)
mx = max(mx, Bei[i]); cout << mx << '\n'; vector<int> ans;
for (int i = 1; i <= n; i ++)
if (Bei[i] == mx)
ans.push_back(i); for (auto i : ans)
cout << i << " \n"[i == ans.back()]; return 0;
}

7-11 名人堂与代金券 - SMU 2024 spring 天梯赛自主训练3 (pintia.cn)

模拟;

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); int n,g,k;
cin >> n >> g >> k;
vector<pair<string,int>> s(n); int sum = 0;
for(auto &[x,y] : s){
cin >> x >> y;
if(y >= g) sum += 50;
else if(y >= 60) sum += 20;
} sort(s.begin(),s.end(),[](pair<string,int> a,pair<string,int> b){
if(a.second != b.second) return a.second > b.second;
return a.first < b.first;
}); cout << sum << '\n'; int now = 1;
for(int i = 0;i < n;i ++){
int cnt = 1;
cout << now << ' ' << s[i].first << ' ' << s[i].second << '\n';
while(i + 1 < n && s[i].second == s[i + 1].second){
i ++;
cnt ++;
cout << now << ' ' << s[i].first << ' ' << s[i].second << '\n';
}
now += cnt;
if(now > k) break;
} return 0;
}

7-12 秀恩爱分得快 - SMU 2024 spring 天梯赛自主训练3 (pintia.cn)

这题我真的很想吐槽下;

wa了30多发,感觉很ex啊,有0和-0这玩意,而且还有可能两者就没出现在照片里过,还有些函数像是abs,stoi啊,能用一次就用一次,不要多次调用,本来\(\mathcal{O}(mk^2)\)的复杂度也很难过吧,没过那就要要注意一下上面的点,还是冲过去了,400多ms,还有就是可以用vector去记录照片里的人,还有还有,就是最后找出来的ma和mb不能直接比较等于,要和他们各自对对方的亲密度比较,就因为这个玩意一直在测试点5wa,真的服了;

#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 val(n, vector<double>(n, 0));
vector<int> fu(n, 1); for (int i = 0; i < m; i ++) {
int k;
cin >> k;
vector<int> people(k);
for (int j = 0; j < k; j ++) {
string s;
cin >> s;
int x = stoi(s);
if (s[0] == '-') x = -x, fu[x] = -1;
people[j] = x;
}
double ok = 1.0 / k;
for (int l = 0; l < k; l ++) {
for (int r = l + 1; r < k; r ++) {
int j = people[l], p = people[r];
if (fu[j] != fu[p]) {
val[j][p] += ok;
val[p][j] += ok;
}
}
}
} int a, b;
string x, y;
cin >> x >> y;
a = stoi(x), b = stoi(y);
if (x[0] == '-') a = -a, fu[a] = -1;
if (y[0] == '-') b = -b, fu[b] = -1;
double ma = 0, mb = 0;
for (int i = 0; i < n; i ++) {
if (fu[i] != fu[a])
ma = max(ma, val[a][i]);
if (fu[i] != fu[b])
mb = max(mb, val[b][i]);
} auto print = [&](int x, int y) {
if (fu[x] == -1) cout << '-';
cout << x << ' ';
if (fu[y] == -1) cout << '-';
cout << y << '\n';
}; if (ma == val[a][b] && mb == val[b][a]) {
print(a, b);
} else {
for (int i = 0; i < n; i ++) {
if (val[a][i] == ma && fu[a] != fu[i]) {
print(a, i);
}
}
for (int i = 0; i < n; i ++) {
if (val[b][i] == mb && fu[b] != fu[i]) {
print(b, i);
}
}
} return 0;
}

SMU 2024 spring 天梯赛自主训练3的更多相关文章

  1. 2018天梯赛第一次训练题解和ac代码

    随着评讲的进行代码和题解会逐步放上来 2018天梯赛第一次训练 1001 : 进制转换 Time Limit(Common/Java):1000MS/10000MS     Memory Limit: ...

  2. PTA天梯赛训练题L1-064:估值一亿的AI核心代码(字符串模拟)

    Update:smz说regex秒过Orz,yzd记在这里了. 听说今年天梯赛有个烦人的模拟,我便被队友逼着试做一下……一发15,二发20.记一记,要不然枉费我写这么久…… 自己还是代码能力太菜了,校 ...

  3. 【CCCC天梯赛决赛】

    cccc的天梯赛决赛,水题一样的水,中档题以上的还是没做出来.补了一下题,觉得其实也不是很难,主要是练的少. L2-1:红色预警 并查集 我做的时候想不到并查集,想到了也不一定做的出来,都是其实不难. ...

  4. 记第一届 CCCC-团体程序设计天梯赛决赛 参赛

    其他都没什么,上午报道,下午比赛两个半小时,最后139分 但四我超遗憾的是,最后在做L3-1二叉搜索树,因为看到有辣么多人做出来,可是我没做出来啊 比赛结束后看了看其他两道当场吐血,L3-3直捣黄龙不 ...

  5. L1-049 天梯赛座位分配​​​​​​​

    L1-049 天梯赛座位分配 (20 分) 天梯赛每年有大量参赛队员,要保证同一所学校的所有队员都不能相邻,分配座位就成为一件比较麻烦的事情.为此我们制定如下策略:假设某赛场有 N 所学校参赛,第 i ...

  6. 团体程序设计天梯赛(CCCC) L3021 神坛 的一些错误做法(目前网上的方法没一个是对的) 和 一些想法

    团体程序设计天梯赛代码.体现代码技巧,比赛技巧.  https://github.com/congmingyige/cccc_code

  7. 团体程序设计天梯赛(CCCC) L3019 代码排版 方法与编译原理密切相关,只有一个测试点段错误

    团体程序设计天梯赛代码.体现代码技巧,比赛技巧.  https://github.com/congmingyige/cccc_code

  8. 团体程序设计天梯赛(CCCC) L3015 球队“食物链” 状态压缩

    团体程序设计天梯赛代码.体现代码技巧,比赛技巧.  https://github.com/congmingyige/cccc_code #include <cstdio> #include ...

  9. 第四届CCCC团体程序设计天梯赛 后记

    一不小心又翻车了,第二次痛失200分 1.开局7分钟A了L2-3,一看榜已经有七个大兄弟排在前面了,翻车 * 1 2.把L1-3 A了18分,留了两分准备抢顽强拼搏奖,最后五秒钟把题过了,万万没想到还 ...

  10. 山东省ACM多校联盟省赛个人训练第六场 poj 3335 D Rotating Scoreboard

    山东省ACM多校联盟省赛个人训练第六场 D Rotating Scoreboard https://vjudge.net/problem/POJ-3335 时间限制:C/C++ 1秒,其他语言2秒 空 ...

随机推荐

  1. RSA密码系统的特定密钥泄露攻击与Coppersmith方法的应用

    PrimiHub一款由密码学专家团队打造的开源隐私计算平台,专注于分享数据安全.密码学.联邦学习.同态加密等隐私计算领域的技术和内容. RSA密码系统作为当前最广泛使用的公钥加密算法之一,其安全性依赖 ...

  2. 【资料分享】全志科技T507-H工业核心板规格书

    1 核心板简介 创龙科技SOM-TLT507是一款基于全志科技T507-H处理器设计的4核ARM Cortex-A53全国产工业核心板,主频高达1.416GHz.核心板CPU.ROM.RAM.电源.晶 ...

  3. Python 潮流周刊#59:Polars 1.0 发布了,PyCon US 2024 演讲视频也发布了(摘要)

    本周刊由 Python猫 出品,精心筛选国内外的 250+ 信息源,为你挑选最值得分享的文章.教程.开源项目.软件工具.播客和视频.热门话题等内容.愿景:帮助所有读者精进 Python 技术,并增长职 ...

  4. 树莓派4B-控制霍尔编码器

    霍尔编码器-直流减速电机 介绍 直流减速电机,即齿轮减速电机,是在普通直流电机的基础上,加上配套齿轮减速箱.齿轮减速箱的作用是,提供较低的转速,较大的力矩.同时,齿轮箱不同的减速比可以提供不同的转速和 ...

  5. 新版SpringBoot-Spring-Mybatis 数据库相关配置

    application.properties server.port=8081 # ========================数据库相关配置===================== sprin ...

  6. C#——接口

    先来看看微软官方对接口的定义与说明. 接口定义协定. 实现接口的类或结构必须遵循它的协定. 接口可以从多个基接口继承,类或结构可以实现多个接口. 接口可以包含方法.属性.事件和索引器. 接口本身不提供 ...

  7. [oeasy]python0091_仙童公司_八叛逆_intel_8080_altair8800_牛郎星

    编码进化 个人电脑 计算机 通过电话网络 进行连接 极客 利用技术 做一些有趣的尝试 极客文化 是 认真研究技术的 文化 计算机 不再是 高校和研究机构高墙里面的 神秘事物 而是 生活中常见的 家用电 ...

  8. CF858C 题解

    洛谷链接&CF 链接 本篇题解为此题较简单做法及较少码量,并且码风优良,请放心阅读. 题目简述 给你一个均为小写字母的字符串,如果它的子串同时满足: 三个连着的辅音字母. 这一段连着的辅音字母 ...

  9. 单细胞测序最好的教程(十四)测序原始数据公开至NCBI数据库

    作者按 国内对于单细胞测序相关的中文教程确实不够全面,当然NCBI官网给的上传教程也比较详细了,所以变成了会者不难.本教程你现在可能用不上,但是你如果做单细胞测序,那么未来你一定会用上,建议收藏. 在 ...

  10. Vue入门记录(一)

    效果 本文为实现如下前端效果的学习实践记录: 实践 入门的最佳实践我觉得是先去看官网,官网一般都会有快速入门指引. 根据官网的快速上手文档,构建一个新的Vue3+TypeScript,查看新建的项目结 ...