SMU 2024 spring 天梯赛自主训练2

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

PHP

点击查看代码
I

L
o
v
e G
P
L
T

7-2 是不是太胖了 - SMU 2024 spring 天梯赛自主训练2 (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 h;
cin >> h;
printf("%.1lf",(h-100)*0.9 * 2); return 0;
}

7-3 大笨钟 - SMU 2024 spring 天梯赛自主训练2 (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 h,m;
char op;
cin >> h >> op >> m;
int now = h * 60 + m;
if(now >= 0 && now <= 12* 60){
printf("Only %02d:%02d. Too early to Dang.",h,m);
}else{
for(int i = 0;i < (now + 59) / 60 - 12 ;i ++)
cout << "Dang";
} return 0;
}

7-4 到底是不是太胖了 - SMU 2024 spring 天梯赛自主训练2 (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 t;
cin >> t;
while(t -- ){
double h,w;
cin >> h >> w;
double Per = (h-100)*0.9*2;
double Nor = Per * 0.1;
if(fabs(w - Per) < Nor)
cout << "You are wan mei!\n";
else if(w > Per)
cout << "You are tai pang le!\n";
else
cout << "You are tai shou le!\n"; } return 0;
}

7-5 情人节 - SMU 2024 spring 天梯赛自主训练2 (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); vector<string> s;
string str;
cin >> str;
while(str != "."){
s.push_back(str);
cin >> str;
} if(s.size() < 2){
cout << "Momo... No one is for you ...\n";
}else if(s.size() < 14)
cout << s[1] << " is the only one for you...\n";
else cout<< s[1] << " and " << s[13] << " are inviting you to dinner..."; return 0;
}

7-6 外星人的一天 - SMU 2024 spring 天梯赛自主训练2 (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 t;
cin >> t;
while(t --){
int d,h,m,now;
char c;
cin >> d >> h >> c >> m;
now = h * 60 + m;
if(!d)
printf("%d %02d:%02d\n",d,h,m);
else {
if(d % 2 == 0) now += 24*60;
printf("%d %02d:%02d\n",(d+1)/2,now / 60 / 2,(now/2)%60);
}
} return 0;
}

7-7 宇宙无敌加法器 - SMU 2024 spring 天梯赛自主训练2 (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); string JIn;
string NumA, NumB;
cin >> JIn >> NumA >> NumB;
vector<int> wei(30);
reverse(JIn.begin(),JIn.end());
reverse(NumA.begin(),NumA.end());
reverse(NumB.begin(),NumB.end());
string zero = "000000000000000000000";
JIn += zero,NumA += zero, NumB += zero;
vector<int> w(30);
string ans = "000000000000000000000";
for(int i = 0;i <= 20;i ++){
int l = JIn[i] - '0';
if(!l) l = 10;
int num = (NumA[i] - '0') + (NumB[i] - '0') + w[i];
w[i+1] += num / l;
ans[i] = char('0' + num % l);
}
reverse(ans.begin(),ans.end());
for(int i = 0;i < ans.size();i ++){
if(ans[i] != '0'){
cout << ans.substr(i) << '\n';
return 0;
}
}
cout << 0 << '\n';
return 0;
}

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

先补充到n的整数倍,然后倒序每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;
cin >> n;
string s;
getline(cin,s);
getline(cin,s); int m = s.size();
if(m % n){
for(int i = 0;i < n - m % n;i ++)
s += ' ';
m = s.size();
}
int dex = n;
reverse(s.begin(),s.end());
for(int i = 0;i < n;i ++){
dex --;
for(int j=dex;j < m;j += n)
cout << s[j];
cout << '\n';
} return 0;
}

7-9 抢红包 - SMU 2024 spring 天梯赛自主训练2 (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 people{
int id,num = 0;
double val = 0;
}; int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); int n;
cin >> n;
vector<people> Ke(n + 1);
for(int i = 1;i <= n;i ++){
int k,num = 0;
cin >> k;
Ke[i].id = i;
for(int j = 0;j < k;j ++){
int ni,pi;
cin >> ni >> pi;
num += pi;
Ke[ni].num ++;
Ke[ni].val += pi;
}
Ke[i].val -= num;
} Ke.erase(Ke.begin());
sort(Ke.begin(),Ke.end(),[&](people a,people b){
if(a.val == b.val && a.num == b.num) return a.id < b.id;
if(a.val == b.val) return a.num > b.num;
return a.val > b.val;
}); for(auto [id,num,val] : Ke){
printf("%d %.2lf\n",id, val / 100);
} return 0;
}

7-10 家庭房产 - SMU 2024 spring 天梯赛自主训练2 (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 people {
int id = -1, num, fang, s;
double avgs, avgfang;
}; int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr); int n;
cin >> n;
vector<int> fa(10010);
iota(fa.begin(), fa.end(), 0); auto find = [&](auto self, int x)-> int{
return fa[x] == x ? x : fa[x] = self(self, fa[x]);
}; bitset<10010> vis;
vector<people> info(10010);
for (int i = 0; i < n; i ++) {
int id, x, y, k, f, s;
cin >> id >> x >> y >> k;
int u = find(find, id);
vis[id] = 1;
if (x != -1) {
x = find(find, x);
vis[x] = 1;
fa[x] = u;
}
if (y != -1) {
y = find(find, y);
vis[y] = 1;
fa[y] = u;
}
for (int j = 0; j < k; j ++) {
int z;
cin >> z;
vis[z] = 1;
z = find(find, z);
fa[z] = u;
}
cin >> f >> s;
info[id] = {id, 1, f, s, 0, 0};
} vector<people> res(10010), ans;
set<int> exit;
for (int i = 0; i < 10000; i ++) {
if (vis[i]) {
int u = find(find, i);
if (res[u].id == -1) res[u].id = i;
res[u].num ++;
res[u].fang += info[i].fang;
res[u].s += info[i].s;
exit.insert(u);
}
} for (auto v : exit) {
ans.push_back(res[v]);
}
for (auto &i : ans) {
i.avgs = i.s * 1.0 / i.num;
i.avgfang = i.fang * 1.0 / i.num;
} sort(ans.begin(), ans.end(), [&](people a, people b) {
if (a.avgs != b.avgs) return a.avgs > b.avgs;
return a.id < b.id;
}); printf("%d\n", ans.size());
for (auto i : ans) {
printf("%04d %d %.3lf %.3lf\n", i.id, i.num, i.avgfang, i.avgs);
} return 0;
}

7-11 功夫传人 - SMU 2024 spring 天梯赛自主训练2 (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;
double r;
cin >> n;
vector<double> z(n + 1);
vector<int> DeDao(n + 1);
cin >> z[0] >> r;
vector g(n + 1, vector<int>());
for (int i = 0; i < n; i ++) {
int k, x;
cin >> k;
if (!k) cin >> x, DeDao[i] = x;
else {
for (int j = 0; j < k; j ++) {
cin >> x;
g[i].push_back(x);
}
}
} double ans = 0;
auto dfs = [&](auto self, int now) {
if (DeDao[now]) {
ans += z[now] * DeDao[now];
return;
} for (auto v : g[now]) {
z[v] = z[now] * (100 - r) * 0.01;
self(self, v);
} }; dfs(dfs, 0); cout << (int) ans << '\n'; return 0;
}

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

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

#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 st, n;
cin >> st >> n;
vector<PII> L1(n), L2(n);
vector<PII> Num(100100);
for (int i = 0; i < n; i ++) {
int x, a, addr;
cin >> addr >> a >> x;
Num[addr] = {a, x};
} int cnt1 = 0, cnt2 = 0;
set<int> vis;
while (st != -1) {
if (vis.count(abs(Num[st].first))) {
L2[cnt2 ++] = {Num[st].first, st};
} else {
vis.insert(abs(Num[st].first));
L1[cnt1 ++] = {Num[st].first, st};
}
st = Num[st].second;
} auto print = [](int cnt, vector<PII> &L) -> void{
for (int i = 0; i < cnt; i ++) {
printf("%05lld %lld ", L[i].second, L[i].first);
if (i == cnt - 1) printf("-1\n");
else printf("%05lld\n", L[i + 1].second);
}
}; print(cnt1, L1);
print(cnt2, L2); return 0;
}

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. 反模式 DI anti-patterns

    反模式 DI anti-patterns 反模式DI anti-patterns <Dependency Injecttion Prinsciples,Practices, and Patter ...

  2. Playbook条件语句

    目录 Playbook条件语句 1. when的基本使用 1.1 when的基本示例 1.2比较运算符 1.3 比较运算符示例 1.4 逻辑运算符 1.5 逻辑运算符示例 2. 条件判断与block ...

  3. Python 安装 matlabengin 时遇到报错:setup.py install is deprecated. !! 以及 Cannot update time stamp of directory 'dist\matlabengine.egg-info' 的解决方案

    目录 Python 安装 matlabengin 时遇到报错:setup.py install is deprecated. !! 以及 Cannot update time stamp of dir ...

  4. Android 8.0 开机时间优化

    Android 8.0 开机时间优化 背景 在嵌入式行业中,有些搭载 了Android系统的设备由于 开机时间 过长而导致无法被接受. 介绍 启动时间是系统性能的重要组成部分,因为用户必须等待启动完成 ...

  5. arm linux 移植 i2c-tools 与 简单使用

    介绍 i2c-tool是一个专门调试i2c的开源工具.可获取挂载的设备及设备地址,还可以在对应的设备指定寄存器设置值或者获取值等功能,对于驱动以及应用开发者比较友好. i2c-tool:v3.0.3 ...

  6. ZYNQ:使用 PetaLinux 构建Linux项目

    参考文档:ug1144-petalinux-tools-reference-guide.pdf 环境安装 tofrodos iproute2 gawk gcc g++ git make net-too ...

  7. LaTeX 编辑协作平台 Overleaf 安装和使用教程

    在学术界和科技行业,LaTeX 已成为撰写高质量文档的标准工具.然而,传统的 LaTeX 使用体验常常伴随着以下挑战: 学习曲线陡峭 环境配置复杂 多人协作困难 实时预览不便 当然,市面上不乏很多在线 ...

  8. ComfyUI进阶篇:ComfyUI核心节点(三)

    ComfyUI核心节点(三) 前言: 学习ComfyUI是一场持久战.当你掌握了ComfyUI的安装和运行之后,会发现大量五花八门的节点.面对各种各样的工作流和复杂的节点种类,可能会让人感到不知所措. ...

  9. 解决方案 | Python中安装pix2tex latex ocr出现报错Cannot mix incompatible Qt library (6.6.2) with this library (6.7.2)

    一.问题 Python中安装pix2tex latex ocr出现报错Cannot mix incompatible Qt library (6.6.2) with this library (6.7 ...

  10. WebGL压缩纹理实践

    0x01 本文将讲述压缩纹理在实际项目中的使用的案例.最近的一个项目是这样的:项目由于涉及到的建筑物特别多,大概有近40栋的建筑,而每一栋建筑物,又有10层楼,每层楼里面又有很多的设备.这就导致我们需 ...