SMU 2024 spring 天梯赛自主训练2
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的更多相关文章
- 2018天梯赛第一次训练题解和ac代码
随着评讲的进行代码和题解会逐步放上来 2018天梯赛第一次训练 1001 : 进制转换 Time Limit(Common/Java):1000MS/10000MS Memory Limit: ...
- PTA天梯赛训练题L1-064:估值一亿的AI核心代码(字符串模拟)
Update:smz说regex秒过Orz,yzd记在这里了. 听说今年天梯赛有个烦人的模拟,我便被队友逼着试做一下……一发15,二发20.记一记,要不然枉费我写这么久…… 自己还是代码能力太菜了,校 ...
- 【CCCC天梯赛决赛】
cccc的天梯赛决赛,水题一样的水,中档题以上的还是没做出来.补了一下题,觉得其实也不是很难,主要是练的少. L2-1:红色预警 并查集 我做的时候想不到并查集,想到了也不一定做的出来,都是其实不难. ...
- 记第一届 CCCC-团体程序设计天梯赛决赛 参赛
其他都没什么,上午报道,下午比赛两个半小时,最后139分 但四我超遗憾的是,最后在做L3-1二叉搜索树,因为看到有辣么多人做出来,可是我没做出来啊 比赛结束后看了看其他两道当场吐血,L3-3直捣黄龙不 ...
- L1-049 天梯赛座位分配
L1-049 天梯赛座位分配 (20 分) 天梯赛每年有大量参赛队员,要保证同一所学校的所有队员都不能相邻,分配座位就成为一件比较麻烦的事情.为此我们制定如下策略:假设某赛场有 N 所学校参赛,第 i ...
- 团体程序设计天梯赛(CCCC) L3021 神坛 的一些错误做法(目前网上的方法没一个是对的) 和 一些想法
团体程序设计天梯赛代码.体现代码技巧,比赛技巧. https://github.com/congmingyige/cccc_code
- 团体程序设计天梯赛(CCCC) L3019 代码排版 方法与编译原理密切相关,只有一个测试点段错误
团体程序设计天梯赛代码.体现代码技巧,比赛技巧. https://github.com/congmingyige/cccc_code
- 团体程序设计天梯赛(CCCC) L3015 球队“食物链” 状态压缩
团体程序设计天梯赛代码.体现代码技巧,比赛技巧. https://github.com/congmingyige/cccc_code #include <cstdio> #include ...
- 第四届CCCC团体程序设计天梯赛 后记
一不小心又翻车了,第二次痛失200分 1.开局7分钟A了L2-3,一看榜已经有七个大兄弟排在前面了,翻车 * 1 2.把L1-3 A了18分,留了两分准备抢顽强拼搏奖,最后五秒钟把题过了,万万没想到还 ...
- 山东省ACM多校联盟省赛个人训练第六场 poj 3335 D Rotating Scoreboard
山东省ACM多校联盟省赛个人训练第六场 D Rotating Scoreboard https://vjudge.net/problem/POJ-3335 时间限制:C/C++ 1秒,其他语言2秒 空 ...
随机推荐
- UIController转为SwiftUI
在UIKit转到SwiftUI的过渡时期中,项目中会遇到不得不用到二者混合使用的情景,苹果这时提供了相关API让iOSer更好地适应这个时期. UIViewControllerRepresentabl ...
- 认真学习CSS3-问题收集-102号-关于定位
css中有关于定位的一个属性position. 在w3cschool中,position的介绍如下: 值 描述 absolute 生成绝对定位的元素,相对于 static 定位以外的第一个父元素进行定 ...
- ZYNQ:Linux添加I2C-RTC驱动
硬件情况 使用的是DS1338这款RTC时钟芯片,I2C总线对应到PS端的I2C1. 配置 内核 添加有关的驱动: 因为DS1338用的驱动与DS13307相似,一找发现是同一个配置. CONFIG_ ...
- vba--数组,多个表中的程序合并到一起,设置为一个按钮
Sub ttt() t = Timer Application.DisplayAlerts = False '清空数据 Sheets("买卖4").Select Range(&qu ...
- saltStack自动化工具
目录 SaltStack自动化工具 核心概念 1. Master 和 Minion 2. State 3. Pillar 4. Grains 5. Modules 6. Runner 7. React ...
- Day 2 - 分治、倍增、LCA 与树链剖分
分治的延伸应用 应用场景 优化合并 假设将两个规模 \(\frac{n}{2}\) 的信息合并为 \(n\) 的时间复杂度为 \(f(n)\),用主定理分析时间复杂度 \(T(n) = 2 \time ...
- TIER 0: Fawn
FTP FTP(File Transfer Protocol)是一种用于在网络上进行文件传输的协议和相应的工具 RFC 959 文档:是定义了 FTP 协议的规范 FTP 使用两个不同的端口 TCP/ ...
- npm私服 verdaccio 搭建
1.什么是npm 私服 我们前端(web,nodejs)平常使用的各种包,什么vue,react,react-router, zustand等,都会从 https://registry.npmjs.o ...
- 缓存框架 Caffeine 的可视化探索与实践
作者:vivo 互联网服务器团队- Wang Zhi Caffeine 作为一个高性能的缓存框架而被大量使用.本文基于Caffeine已有的基础进行定制化开发实现可视化功能. 一.背景 Caffei ...
- java开发,json转list集合,原生实现
java 是一门面象对象的语言,对象需要先定义,但是在外理网络请求时候会用到json 转成java 对象,虽然现代开发框架中也提供了很多工具和方法直接转换, 但是作为学习者了解 一下底层实现,更能灵活 ...