SMU 2024 spring 天梯赛自主训练2

7-1 I Love GPLT - SMU 2024 spring 天梯赛自主训练2 (pintia.cn)

PHP

点击查看代码
  1. I
  2. L
  3. o
  4. v
  5. e
  6. G
  7. P
  8. L
  9. T

7-2 是不是太胖了 - SMU 2024 spring 天梯赛自主训练2 (pintia.cn)

  1. #include <bits/stdc++.h>
  2. #define debug(a) cout<<#a<<"="<<a<<'\n';
  3. using namespace std;
  4. using i64 = long long;
  5. typedef pair<i64, i64> PII;
  6. int main() {
  7. ios::sync_with_stdio(false);
  8. cin.tie(nullptr);
  9. int h;
  10. cin >> h;
  11. printf("%.1lf",(h-100)*0.9 * 2);
  12. return 0;
  13. }

7-3 大笨钟 - SMU 2024 spring 天梯赛自主训练2 (pintia.cn)

  1. #include <bits/stdc++.h>
  2. #define debug(a) cout<<#a<<"="<<a<<'\n';
  3. using namespace std;
  4. using i64 = long long;
  5. typedef pair<i64, i64> PII;
  6. int main() {
  7. ios::sync_with_stdio(false);
  8. cin.tie(nullptr);
  9. int h,m;
  10. char op;
  11. cin >> h >> op >> m;
  12. int now = h * 60 + m;
  13. if(now >= 0 && now <= 12* 60){
  14. printf("Only %02d:%02d. Too early to Dang.",h,m);
  15. }else{
  16. for(int i = 0;i < (now + 59) / 60 - 12 ;i ++)
  17. cout << "Dang";
  18. }
  19. return 0;
  20. }

7-4 到底是不是太胖了 - SMU 2024 spring 天梯赛自主训练2 (pintia.cn)

  1. #include <bits/stdc++.h>
  2. #define debug(a) cout<<#a<<"="<<a<<'\n';
  3. using namespace std;
  4. using i64 = long long;
  5. typedef pair<i64, i64> PII;
  6. int main() {
  7. ios::sync_with_stdio(false);
  8. cin.tie(nullptr);
  9. int t;
  10. cin >> t;
  11. while(t -- ){
  12. double h,w;
  13. cin >> h >> w;
  14. double Per = (h-100)*0.9*2;
  15. double Nor = Per * 0.1;
  16. if(fabs(w - Per) < Nor)
  17. cout << "You are wan mei!\n";
  18. else if(w > Per)
  19. cout << "You are tai pang le!\n";
  20. else
  21. cout << "You are tai shou le!\n";
  22. }
  23. return 0;
  24. }

7-5 情人节 - SMU 2024 spring 天梯赛自主训练2 (pintia.cn)

  1. #include <bits/stdc++.h>
  2. #define debug(a) cout<<#a<<"="<<a<<'\n';
  3. using namespace std;
  4. using i64 = long long;
  5. typedef pair<i64, i64> PII;
  6. int main() {
  7. ios::sync_with_stdio(false);
  8. cin.tie(nullptr);
  9. vector<string> s;
  10. string str;
  11. cin >> str;
  12. while(str != "."){
  13. s.push_back(str);
  14. cin >> str;
  15. }
  16. if(s.size() < 2){
  17. cout << "Momo... No one is for you ...\n";
  18. }else if(s.size() < 14)
  19. cout << s[1] << " is the only one for you...\n";
  20. else cout<< s[1] << " and " << s[13] << " are inviting you to dinner...";
  21. return 0;
  22. }

7-6 外星人的一天 - SMU 2024 spring 天梯赛自主训练2 (pintia.cn)

  1. #include <bits/stdc++.h>
  2. #define debug(a) cout<<#a<<"="<<a<<'\n';
  3. using namespace std;
  4. using i64 = long long;
  5. typedef pair<i64, i64> PII;
  6. int main() {
  7. ios::sync_with_stdio(false);
  8. cin.tie(nullptr);
  9. int t;
  10. cin >> t;
  11. while(t --){
  12. int d,h,m,now;
  13. char c;
  14. cin >> d >> h >> c >> m;
  15. now = h * 60 + m;
  16. if(!d)
  17. printf("%d %02d:%02d\n",d,h,m);
  18. else {
  19. if(d % 2 == 0) now += 24*60;
  20. printf("%d %02d:%02d\n",(d+1)/2,now / 60 / 2,(now/2)%60);
  21. }
  22. }
  23. return 0;
  24. }

7-7 宇宙无敌加法器 - SMU 2024 spring 天梯赛自主训练2 (pintia.cn)

模拟进制;

  1. #include <bits/stdc++.h>
  2. #define debug(a) cout<<#a<<"="<<a<<'\n';
  3. using namespace std;
  4. using i64 = long long;
  5. typedef pair<i64, i64> PII;
  6. int main() {
  7. ios::sync_with_stdio(false);
  8. cin.tie(nullptr);
  9. string JIn;
  10. string NumA, NumB;
  11. cin >> JIn >> NumA >> NumB;
  12. vector<int> wei(30);
  13. reverse(JIn.begin(),JIn.end());
  14. reverse(NumA.begin(),NumA.end());
  15. reverse(NumB.begin(),NumB.end());
  16. string zero = "000000000000000000000";
  17. JIn += zero,NumA += zero, NumB += zero;
  18. vector<int> w(30);
  19. string ans = "000000000000000000000";
  20. for(int i = 0;i <= 20;i ++){
  21. int l = JIn[i] - '0';
  22. if(!l) l = 10;
  23. int num = (NumA[i] - '0') + (NumB[i] - '0') + w[i];
  24. w[i+1] += num / l;
  25. ans[i] = char('0' + num % l);
  26. }
  27. reverse(ans.begin(),ans.end());
  28. for(int i = 0;i < ans.size();i ++){
  29. if(ans[i] != '0'){
  30. cout << ans.substr(i) << '\n';
  31. return 0;
  32. }
  33. }
  34. cout << 0 << '\n';
  35. return 0;
  36. }

7-8 古风排版 - SMU 2024 spring 天梯赛自主训练2 (pintia.cn)

先补充到n的整数倍,然后倒序每n个输出;

  1. #include <bits/stdc++.h>
  2. #define debug(a) cout<<#a<<"="<<a<<'\n';
  3. using namespace std;
  4. using i64 = long long;
  5. typedef pair<i64, i64> PII;
  6. int main() {
  7. ios::sync_with_stdio(false);
  8. cin.tie(nullptr);
  9. int n;
  10. cin >> n;
  11. string s;
  12. getline(cin,s);
  13. getline(cin,s);
  14. int m = s.size();
  15. if(m % n){
  16. for(int i = 0;i < n - m % n;i ++)
  17. s += ' ';
  18. m = s.size();
  19. }
  20. int dex = n;
  21. reverse(s.begin(),s.end());
  22. for(int i = 0;i < n;i ++){
  23. dex --;
  24. for(int j=dex;j < m;j += n)
  25. cout << s[j];
  26. cout << '\n';
  27. }
  28. return 0;
  29. }

7-9 抢红包 - SMU 2024 spring 天梯赛自主训练2 (pintia.cn)

排序;

  1. #include <bits/stdc++.h>
  2. #define debug(a) cout<<#a<<"="<<a<<'\n';
  3. using namespace std;
  4. using i64 = long long;
  5. typedef pair<i64, i64> PII;
  6. struct people{
  7. int id,num = 0;
  8. double val = 0;
  9. };
  10. int main() {
  11. ios::sync_with_stdio(false);
  12. cin.tie(nullptr);
  13. int n;
  14. cin >> n;
  15. vector<people> Ke(n + 1);
  16. for(int i = 1;i <= n;i ++){
  17. int k,num = 0;
  18. cin >> k;
  19. Ke[i].id = i;
  20. for(int j = 0;j < k;j ++){
  21. int ni,pi;
  22. cin >> ni >> pi;
  23. num += pi;
  24. Ke[ni].num ++;
  25. Ke[ni].val += pi;
  26. }
  27. Ke[i].val -= num;
  28. }
  29. Ke.erase(Ke.begin());
  30. sort(Ke.begin(),Ke.end(),[&](people a,people b){
  31. if(a.val == b.val && a.num == b.num) return a.id < b.id;
  32. if(a.val == b.val) return a.num > b.num;
  33. return a.val > b.val;
  34. });
  35. for(auto [id,num,val] : Ke){
  36. printf("%d %.2lf\n",id, val / 100);
  37. }
  38. return 0;
  39. }

7-10 家庭房产 - SMU 2024 spring 天梯赛自主训练2 (pintia.cn)

并查集处理家庭关系,然后遍历一遍统计家庭所有信息,最后根据题目要求排序;

  1. #include <bits/stdc++.h>
  2. #define debug(a) cout<<#a<<"="<<a<<'\n';
  3. using namespace std;
  4. using i64 = long long;
  5. typedef pair<i64, i64> PII;
  6. struct people {
  7. int id = -1, num, fang, s;
  8. double avgs, avgfang;
  9. };
  10. int main() {
  11. ios::sync_with_stdio(false);
  12. cin.tie(nullptr);
  13. int n;
  14. cin >> n;
  15. vector<int> fa(10010);
  16. iota(fa.begin(), fa.end(), 0);
  17. auto find = [&](auto self, int x)-> int{
  18. return fa[x] == x ? x : fa[x] = self(self, fa[x]);
  19. };
  20. bitset<10010> vis;
  21. vector<people> info(10010);
  22. for (int i = 0; i < n; i ++) {
  23. int id, x, y, k, f, s;
  24. cin >> id >> x >> y >> k;
  25. int u = find(find, id);
  26. vis[id] = 1;
  27. if (x != -1) {
  28. x = find(find, x);
  29. vis[x] = 1;
  30. fa[x] = u;
  31. }
  32. if (y != -1) {
  33. y = find(find, y);
  34. vis[y] = 1;
  35. fa[y] = u;
  36. }
  37. for (int j = 0; j < k; j ++) {
  38. int z;
  39. cin >> z;
  40. vis[z] = 1;
  41. z = find(find, z);
  42. fa[z] = u;
  43. }
  44. cin >> f >> s;
  45. info[id] = {id, 1, f, s, 0, 0};
  46. }
  47. vector<people> res(10010), ans;
  48. set<int> exit;
  49. for (int i = 0; i < 10000; i ++) {
  50. if (vis[i]) {
  51. int u = find(find, i);
  52. if (res[u].id == -1) res[u].id = i;
  53. res[u].num ++;
  54. res[u].fang += info[i].fang;
  55. res[u].s += info[i].s;
  56. exit.insert(u);
  57. }
  58. }
  59. for (auto v : exit) {
  60. ans.push_back(res[v]);
  61. }
  62. for (auto &i : ans) {
  63. i.avgs = i.s * 1.0 / i.num;
  64. i.avgfang = i.fang * 1.0 / i.num;
  65. }
  66. sort(ans.begin(), ans.end(), [&](people a, people b) {
  67. if (a.avgs != b.avgs) return a.avgs > b.avgs;
  68. return a.id < b.id;
  69. });
  70. printf("%d\n", ans.size());
  71. for (auto i : ans) {
  72. printf("%04d %d %.3lf %.3lf\n", i.id, i.num, i.avgfang, i.avgs);
  73. }
  74. return 0;
  75. }

7-11 功夫传人 - SMU 2024 spring 天梯赛自主训练2 (pintia.cn)

dfs弟子递归,遇到传道者累加答案即可;

  1. #include <bits/stdc++.h>
  2. #define debug(a) cout<<#a<<"="<<a<<'\n';
  3. using namespace std;
  4. using i64 = long long;
  5. typedef pair<i64, i64> PII;
  6. int main() {
  7. ios::sync_with_stdio(false);
  8. cin.tie(nullptr);
  9. int n;
  10. double r;
  11. cin >> n;
  12. vector<double> z(n + 1);
  13. vector<int> DeDao(n + 1);
  14. cin >> z[0] >> r;
  15. vector g(n + 1, vector<int>());
  16. for (int i = 0; i < n; i ++) {
  17. int k, x;
  18. cin >> k;
  19. if (!k) cin >> x, DeDao[i] = x;
  20. else {
  21. for (int j = 0; j < k; j ++) {
  22. cin >> x;
  23. g[i].push_back(x);
  24. }
  25. }
  26. }
  27. double ans = 0;
  28. auto dfs = [&](auto self, int now) {
  29. if (DeDao[now]) {
  30. ans += z[now] * DeDao[now];
  31. return;
  32. }
  33. for (auto v : g[now]) {
  34. z[v] = z[now] * (100 - r) * 0.01;
  35. self(self, v);
  36. }
  37. };
  38. dfs(dfs, 0);
  39. cout << (int) ans << '\n';
  40. return 0;
  41. }

7-12 链表去重 - SMU 2024 spring 天梯赛自主训练2 (pintia.cn)

开1e6的数组用对应地址记录结点信息以及下一个地址,按初始地址构建两条链,碰到重复的就丢到另一条链;

  1. #include <bits/stdc++.h>
  2. #define debug(a) cout<<#a<<"="<<a<<'\n';
  3. using namespace std;
  4. using i64 = long long;
  5. typedef pair<i64, i64> PII;
  6. int main() {
  7. ios::sync_with_stdio(false);
  8. cin.tie(nullptr);
  9. int st, n;
  10. cin >> st >> n;
  11. vector<PII> L1(n), L2(n);
  12. vector<PII> Num(100100);
  13. for (int i = 0; i < n; i ++) {
  14. int x, a, addr;
  15. cin >> addr >> a >> x;
  16. Num[addr] = {a, x};
  17. }
  18. int cnt1 = 0, cnt2 = 0;
  19. set<int> vis;
  20. while (st != -1) {
  21. if (vis.count(abs(Num[st].first))) {
  22. L2[cnt2 ++] = {Num[st].first, st};
  23. } else {
  24. vis.insert(abs(Num[st].first));
  25. L1[cnt1 ++] = {Num[st].first, st};
  26. }
  27. st = Num[st].second;
  28. }
  29. auto print = [](int cnt, vector<PII> &L) -> void{
  30. for (int i = 0; i < cnt; i ++) {
  31. printf("%05lld %lld ", L[i].second, L[i].first);
  32. if (i == cnt - 1) printf("-1\n");
  33. else printf("%05lld\n", L[i + 1].second);
  34. }
  35. };
  36. print(cnt1, L1);
  37. print(cnt2, L2);
  38. return 0;
  39. }

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

  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. Linux中的环境变量PS1,打造你的专属终端

    文章目录 介绍 PS1的格式 设置字体样式 举例 小建议 进阶 介绍 好看的终端是怎么做的呢?通过PS1这个环境变量! PS1的格式 PS1='[\u@\h \w]\$ ' 样式: 解释: [是普通字 ...

  2. .NET 认识日志系统-2

    .NET 日志系统2 上一篇文章是将日志打印到控制台,这篇文章将日志写入到文本文件中. 文本日志一般按照日期区分 如何避免文本日志把磁盘撑爆? 限制日志总个数或者总大小 如何避免一个日志文件太大? 限 ...

  3. arm 移植 lighttpd + CGI 配置

    --- title: arm 移植 lighttpd + CGI 配置 EntryName: porting-lighttpd-on-arm-and-make-cgi-config date: 202 ...

  4. MySQL与Redis数据双写一致性工程落地案例

    复习-面试题 多个线程同时去查询数据库的这条数据,那么我们可以在第一个查询数据的请求上使用一个 互斥锁来锁住它. 其他的线程走到这一步拿不到锁就等着,等第一个线程查询到了数据,然后做缓存. 后面的线程 ...

  5. SafeLine Web 安全网关保护你的网站不受黑客攻击

    SafeLine 简介 今天,推荐给大家的是一款在社区广受好评的网站防护工具 -- SafeLine Web 安全网关. 简单来说这是一个自带安全 buf 的 Nginx,它基于业界领先的语义分析检测 ...

  6. 基于MindSpore实现BERT对话情绪识别

    本文分享自华为云社区<[昇思25天学习打卡营打卡指南-第二十四天]基于 MindSpore 实现 BERT 对话情绪识别>,作者:JeffDing. 模型简介 BERT全称是来自变换器的双 ...

  7. Top monitor[2.1.11] 开源

    说明 本项目将转为开源项目. \(\text{GitHub}\) 仓库下载链接 \(|\) 项目初始化下载 \(|\) 项目编辑文件下载. 项目说明 声明:此项目由 \(\text{So_noSlac ...

  8. 第七节 JMeter基础-高级登录【数据驱动-参数化】

    声明:本文所记录的仅本次操作学习到的知识点,其中商城IP错误,请自行更改. 背景:一个接口的不同情况,其实就是请求参数不一样.期望结果不一样.把这些不一样的东西都提取出来进行管理,下次可以直接使用.因 ...

  9. wails实现腾讯元器bot

    简单记录工具的一个模块 后端 Api调用 登录 腾讯元器 后创建智能体,按自己的需求来创建,发布后要等等审核. ​​ 等发布完成后点击调用api即可,这里可以看到user_id​, assistant ...

  10. 使用 Doxygen 来生成 Box2d 的 API 文档

    对于 Doxygen 以前只听别人说过,而现在使用它也是一个偶然,缘分吧.前两天看 box2d 的官方 sdk 中,发现他有用户手册却没有说明,只是留下了一个 Doxygen 的文件.事情告一段落,然 ...