SMU 2024 spring 天梯赛自主训练3
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的更多相关文章
- 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秒 空 ...
随机推荐
- UniRx-unirx中的对象池
UniRx-unirx中的对象池 对象池Unirxunity 对象池 一.对象池模式 <游戏设计模式-对象池模式> 1.概念 定义一个池对象,其包含了一组可重用对象. 其中每个可重用对象都 ...
- pytest-allure 命令生成的报告,test body 没有具体的参数和日志
run.py: pytest.main([命令参数执行]),pytest命令执行完毕后,使用os.system()执行allure的命令 原因: 使用了命令:os.system('allure gen ...
- 《Objective-C Direct Methods》学习笔记
原文通过对Objective-C发展史.Objective-C中Runtime的动态派发,C语言的直接派发进行铺垫介绍,引出了direct methods这个"新特性"(文章写于2 ...
- 无业游民写的最后一个.net有关项目框架
理想很丰满,现实往往很残酷. 一种按照ddd的方式,根据业务来把自己需要的模块一个一个写出来,再按照模块把需要的接口一个一个的写出来,堆砌一些中间件,以及解耦的command,handler等等 ,一 ...
- ElasticSearch不区分字母大小写搜索
0.停止使用该索引的服务(避免新加了数据没备份) 1.备份filesearch索引(检查备份的索引和原索引数据条数是否一致) 1 POST http://127.0.0.1:9200/_reindex ...
- 【ClickHouse问题】更新表字段类型为Nullable(Int32)的列值,最终结果都是固定一个值:93147008???
问题描述: clickhouse更新表数据.更新的列数据类型是Nullable(Int32),不管更新为什么数值,最后查询的结果都是一个固定值:93147008 问题复现: 1:建一张测试表 CREA ...
- P5494 题解
来一发 \(O(\log n)\) 线性空间的解法. 考虑通过只维护线段树叶子节点的虚树的方法压缩空间,考虑记录下每个节点的编号,然后通过异或完求最低位的 \(1\) 的方式求出 LCA 的深度,然后 ...
- 洛谷P1095
[NOIP2007 普及组] 守望者的逃离 题目背景 恶魔猎手尤迪安野心勃勃,他背叛了暗夜精灵,率领深藏在海底的娜迦族企图叛变. 题目描述 守望者在与尤迪安的交锋中遭遇了围杀,被困在一个荒芜的大岛上. ...
- 2024 年 Visual Studio 实用插件集合
前言 在软件开发领域,选择正确的工具可以极大地提升开发效率和质量. Visual Studio作为微软推出的强大集成开发环境(IDE),通过安装合适的插件,可以进一步增强其功能,满足开发者多样化的需求 ...
- ctfshow sql-labs(笔记)
这是当时做题的时候记得笔记有些乱看不懂的可以私我 判断闭合方式: id=1' and 1=1–+ *正常回显* id=1' and 1=2–+ *异常回显* id=1 and 1=1 *正常回显* i ...