大学生团体天梯赛(第六届)

2023-11-09

题目地址:天梯赛在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int x, cnt; 
int main() {
	while(cin >> x && ++cnt) {
		if(x == 250) {
			cout << cnt;
			return 0;
		}
	}
	return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int y, m, d;
int main() {
	scanf("%d-%d-%d", &m, &d, &y);
	printf("%04d-%02d-%02d", y, m, d);
	return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int n, x, hh, mm, cnt_p, cnt_t;
char c, f;
unordered_map<int,pair<int, int>> mp;
int main() {
	cin >> n;
	for(int i = 0; i < n;) {
		scanf("%d %c %d:%d", &x, &c, &hh, &mm);
		if(!x) {
			++i;
			if(cnt_p == 0) cout << "0 0\n";
			else printf("%d %d\n", cnt_p, (int)(((double)cnt_t  / cnt_p) + 0.5));
			cnt_p = cnt_t = 0;
			mp.clear();
		} else {
			if(c == 'S') {
           		mp[x] = {hh, mm};
			} else if(c == 'E') {
				if(mp.count(x)) {
					++cnt_p, cnt_t += (hh - mp[x].first) * 60 + mm - mp[x].second;
					mp.erase(x);
				}
			}
		}
	}
	return 0;
}
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int k, cnt;
string s;
unordered_map<string, string> mp{
	{"ChuiZi", "Bu"}, {"JianDao", "ChuiZi"}, {"Bu", "JianDao"}
};
int main() {
	cin >> k;
	while(cin >> s && mp.count(s) && ++cnt) {
		if(cnt % (k + 1)) cout << mp[s] << endl;
		else cout << s << endl; 
	}
	return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
string s;
int main() {
	cin >> s;
	cout << "Hello " << s;
	return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int cnt = 1, mod = 1, x;
int main() {
	cin >> x;
	while(mod < x) {
		mod = mod * 10 + 1, ++cnt;
	}
	while(mod % x) {
		cout << mod / x;
		mod %= x, mod = mod * 10 + 1, ++cnt;
	}
	cout << mod / x << " " << cnt;
	return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int n, h, m;
string s;
int main() {
	cin >> n;
	while(n--) {
		cin >> s >> h >> m;
		if(h < 15 || h > 20 || m < 50 || m > 70) {
			cout << s << endl; 
		}
	}
	return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int a[505][505], b[505][505], c[505][505];
int ra, ca, rb, cb;
int main() {
	cin >> ra >> ca;
	for(int i = 0; i < ra; ++i) {
		for(int j = 0; j < ca; ++j) {
			cin >> a[i][j];
		}
	}
	cin >> rb >> cb;
	for(int i = 0; i < rb; ++i) {
		for(int j = 0; j < cb; ++j) {
			cin >> b[i][j];
		}
	}
	if(ca != rb) {
		printf("Error: %d != %d", ca, rb);
	} else {
		cout << ra << " " << cb << endl;
		for(int i = 0; i < ra; ++i) {
			for(int j = 0; j < cb; ++j) {
				int cnt = 0;
				for(int k = 0; k < ca; ++k) {
					cnt += a[i][k] * b[k][j];
				}
				if(j) cout << " "; 
				cout << cnt;
			}
			cout << endl;
		}
	}
	return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int n, k, x;
set<int> st[105];
struct P{
	string name;
	double cnt, avg;
}p[105];
int main() {
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> p[i].name >> k;
		for(int j = 0; j < k; ++j) {
			cin >> x;
			st[i].insert(x);
		}
		p[i].cnt = st[i].size(), p[i].avg = (double)st[i].size() / k;
	}
	sort(p ,p + n, [](P A, P B){
		return A.cnt > B.cnt || A.cnt == B.cnt && A.avg > B.avg;
	});
	if(n < 3) {
		for(int i = 2; i > n - 1;--i) {
			p[i].name = "-";
		}
	}
	cout << p[0].name; 
	for(int i = 1; i < 3; ++i) {
		cout << ' ' << p[i].name;
	}
    return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, cnt;
struct node{
	string address, nxt;
	int data;
}p[N], q;
string now;
unordered_map<string, pair<int, string>> mp;
int main() {
	cin >> now >> n;
	for(int i = 0; i < n; ++i) {
		cin >> q.address >> q.data >> q.nxt;
		mp[q.address] = {q.data, q.nxt};
	}
	while(now != "-1") {
		p[cnt].address = now, p[cnt++].data = mp[now].first, now = mp[now].second;
	}
	for(int l = 0, r = cnt - 1; l <= r; ++l, --r) {
		if(l != r) cout << p[r].address << ' ' << p[r].data << ' ' << p[l].address << endl << p[l].address << ' ' << p[l].data << ' ' << (l + 1 == r ? "-1" : p[r - 1].address) << endl;
		else cout << p[l].address << ' ' << p[l].data << " -1";
	}
    return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int n, e, k, u, v;
int a[505];
bool vis[505];
vector<int> connect[505]; 
bool bfs(int x) {
	queue<int> Q;
	Q.push(x);
	while(!Q.empty()) {
		x = Q.front(), Q.pop();
		if(vis[x]) continue;
		vis[x] = true;
		for(int i = 0; i < connect[x].size(); ++i) {
			if(a[connect[x][i]] == a[x]) return false;
			Q.push(connect[x][i]);
		}
	}
	return true;
}
int main() {
	cin >> n >> e >> k;
	while(e--) {
		cin >> u >> v;
		connect[u].push_back(v), connect[v].push_back(u);
	}
	cin >> e;
	while(e--) {
		set<int> st;
		for(int i = 1; i <= n; ++i) {
			cin >> a[i], st.insert(a[i]);
		}
		if(st.size() != k) {
			cout << "No" << endl;
			continue;
		}
		memset(vis, false, sizeof(vis));
	    for(int i = 1; i <= n; ++i) {
			if(!vis[i] && !bfs(i)) {
				cout << "No" << endl;
				goto here;
			}
		}
		cout << "Yes" << endl; 
here:;}
    return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5;
int n, k, x, cnt, p;
int f[N];
set<int> st;
int find(int x) {
	return x == f[x] ? x : f[x] = find(f[x]);
}
int main() {
	cin >> n;
	for(int i = 0; i < N; ++i) {
		f[i] = i;
	}
	for(int i = 0; i < n; ++i) {
		cin >> k >> p;
		bool flag = true;
		st.insert(p);
		for(int j = 1; j < k; ++j) {
			cin >> x, st.insert(x);
			if(find(x) != find(p)) {
				f[find(x)] = find(p);
			}
		} 
	}
    for(auto& x : st) {
        if(find(x) == x) ++cnt;
    }
	cout << st.size() << ' ' << cnt << endl;
	cin >> n;
	while(n--) {
		cin >> p >> x;
		cout << (find(x) == find(p) ? "Y\n" : "N\n");
	} 
    return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
struct Node {
	int father = -1, val, layer, l_child = -1, r_child = -1;
} node[105];
unordered_map<int, int> mp;
int n, x, a, b, cnt;
string s;
void insert(int x, int root) {
	if(x < node[root].val) {
		if(node[root].l_child == -1) {
			node[root].l_child = cnt;
			node[cnt].val = x, node[cnt].father = root, node[cnt].layer = node[root].layer + 1;
			mp[x] = cnt++;
		} else {
			insert(x, node[root].l_child);
		}
	} else {
		if(node[root].r_child == -1) {
			node[root].r_child = cnt;
			node[cnt].val = x, node[cnt].father = root, node[cnt].layer = node[root].layer + 1;
			mp[x] = cnt++;
		} else {
			insert(x, node[root].r_child);
		}
	}
}
void print(bool check) {
	cout << (check ? "Yes\n" : "No\n");
} 
int main() {
	cin >> n >> x;
	node[cnt].val = x, node[cnt].layer = 1, mp[x] = cnt++;
	for(int i = 1; i < n; ++i) {
		cin >> x;
		insert(x, 0);
	}
	cin >> n;
	while(n--) {
		cin >> a >> s;
		if(s == "is") {
			cin >> s >> s;
			if(s == "root") {
				print(node[0].val == a);
			} else if (s == "parent") {
				cin >> s >> b;
				if(!mp.count(b)) print(false);
				else print(node[node[mp[b]].father].val == a);
			} else if (s == "left") {
				cin >> s >> s >> b;
				if(!mp.count(b) || node[mp[b]].l_child == -1) print(false);
				else print(node[node[mp[b]].l_child].val == a);
			} else if(s == "right"){
				cin >> s >> s >> b;
				if(!mp.count(b) || node[mp[b]].r_child == -1) print(false);
				else print(node[node[mp[b]].r_child].val == a);
			}
		} else if(s == "and") {
			cin >> b >> s >> s;
			if(s == "siblings") {
				if(!mp.count(b) || !mp.count(a)) {
					print(false);
				} else {
					print(node[mp[b]].father == node[mp[a]].father);
				}
			} else {
				cin >> s >> s >> s; 
				if(!mp.count(a) || !mp.count(b)) print(false);
				else print(node[mp[a]].layer == node[mp[b]].layer);
			}
		}
	}
	return 0;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

大学生团体天梯赛(第六届) 的相关文章

  • C# 打印问题(RichTextBox)

    我想打印我的 RichTextBox eintragRichTextBox 的内容 我现在有这个代码 private void druckenPictureBox Click object sender EventArgs e PrintD
  • CMake 找不到请求的 Boost 库

    既然我已经浏览了其他人的解决方案几个小时 但找不到适合我的问题的正确答案 我想将我的具体问题带给您 我正在尝试使用 CMake 构建 vsomeip 为此 我之前构建了 boost 1 55 但是 我在 CMake 中收到以下错误 The
  • 在 Java 中创建 T 的新实例

    在C 中 我们可以定义一个泛型class A
  • 删除是如何工作的? [复制]

    这个问题在这里已经有答案了 可能的重复 C 编程 free 如何知道要释放多少 https stackoverflow com questions 1518711 c programming how does free know how m
  • CSharpRepl emacs 集成?

    我碰巧知道莫诺CSharpRepl http www mono project com CsharpRepl 是否有 emacs csharp 模式使用它在一个窗口中运行 REPL 并像 python 模式一样在另一个窗口中编译 运行 C
  • 在 C# 中调用 C++ 库 [关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 我有很多用 C 编写的库 我想从 C 调用这些库 但是 我遇到了很多问题 我想知道是否有书籍或指南告诉我如何做到这一点 Dll导入 htt
  • C# 5 async/await 线程机制感觉不对?

    为什么让调用线程进入异步方法直到内部 等待 一旦调用异步方法就生成一个线程 这不是更干净吗 这样您就可以确定异步方法会立即返回 您不必担心在异步方法的早期阶段没有做任何昂贵的事情 我倾向于知道某个方法是否要在 我的 线程上执行代码 不管是堵
  • 为什么'enable_if'不能用于禁用这里声明

    include
  • C# 开源 NMEA 解析器 [已关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我正在寻找 C 开源 NMEA 解析器 嗯 我自己也不熟悉 但是一些快速搜索显示了一个代码项目 htt
  • 将表(行)与 OpenXML SDK 2.5 保持在一起

    我想在 Word 文档中生成多个表 每行 2 行 但我想将这两行保留在一起 如果可能的话 new KeepNext 第一行不起作用 new KeepNext 第一行的最后一段不起作用 new CantSplit 放在桌子上不起作用 在所有情
  • 将接口转换为其具体实现对象,反之亦然?

    在 C 中 当我有一个接口和几个具体实现时 我可以将接口强制转换为具体类型 还是将具体类型强制转换为接口 这种情况下的规则是什么 Java 和 C 中都允许这两个方向 向下转型需要显式转型 如果对象类型不正确 可能会抛出异常 然而 向上转换
  • C#6 中的长字符串插值行

    我发现 虽然字符串插值在应用于现有代码库的字符串 Format 调用时非常好 但考虑到通常首选的列限制 字符串对于单行来说很快就会变得太长 特别是当被插值的表达式很复杂时 使用格式字符串 您将获得一个可以拆分为多行的变量列表 var str
  • 在 asp.net MVC 中使用活动目录进行身份验证

    我想使用活动目录对我的 asp net mvc 项目中的用户进行身份验证 在网上冲浪了几个小时后 我没有找到任何对我有用的东西 我已经看到了所有结果 但什么也没有 我尝试按照许多帖子的建议编辑我的 web config 如果有人可以帮助我提
  • 如何使用 NPOI 按地址(A1、A2)获取 Excel 单元格值

    我有一个 Excel 单元格地址 例如 A1 A2 如何使用 C 中的 NPOI 框架以编程方式访问此单元格 我找到的一些 Java POI 示例代码 CellReference cr new CellReference A1 row my
  • 在 OpenGL 中渲染纹理 1 到 1

    所以我想做的是使用 OpenGL 和 C 将纹理渲染到平面上 作为显示图像的一种方式 但是我需要确保在渲染纹理时没有对纹理进行任何处理 抗锯齿 插值 平滑 模糊等 这是 OpenGL 处理渲染纹理的默认方式吗 或者是否需要设置一些标志才能禁
  • 选择查询不适用于使用Parameters.AddWithValue 的参数

    C 中的以下查询不起作用 但我看不出问题所在 string Getquery select from user tbl where emp id emp id and birthdate birthdate cmdR Parameters
  • 如何停止无限循环?

    我正在编写一个程序 该程序将计算三角形或正方形的面积 然后提示用户是否希望计算另一个 我的代码已经运行到可以计算任一形状的面积的程度 但随后不再继续执行代码的其余部分 例如 如果选择了正方形 则计算面积 然后返回到正方形边长的提示 我假设这
  • 如何得知客户端从服务器的下载速度?

    根据客户的下载速度 我想以低质量或高质量显示视频 任何 Javascript 或 C 解决方案都是可以接受的 Thanks 没有任何办法可以确定 您只能测量向客户端发送数据的速度 如果没有来自客户端的任何类型的输入来表明其获取信息的速度 您
  • DataContractSerializer 事件/委托字段问题

    在我的 WPF 应用程序中 我正在使用DataContractSerializer序列化对象 我发现它无法序列化具有事件或委托声明的类型 考虑以下失败的代码 Serializable public abstract class BaseCl
  • 如何将 SQL“LIKE”与 LINQ to Entities 结合使用?

    我有一个文本框 允许用户指定搜索字符串 包括通配符 例如 Joh Johnson mit ack on 在使用 LINQ to Entities 之前 我有一个存储过程 该存储过程将该字符串作为参数并执行以下操作 SELECT FROM T

随机推荐

  • 【点云处理技术之PCL】滤波器——直通滤波器(pcl::PassThrough)

    直通滤波器 是直接根据滤波器设定的条件 选择自己所需点云 可以选择保留设定范围内的点云 也可以选择滤除设定范围内的点云 保留或者滤出是由setFilterLimitsNegative进行模式开关的 代码中 设定z轴的条件 保留z方向范围 0
  • python pool.map 多线程 多参数

    python pool map 多线程 多参数 pool map默认只能传入一个参数 包上一个lambda分发参数 即可解决多参数传入问题 from multiprocessing import Pool from multiprocess
  • 数据挖掘中的数据清洗方法大全

    作者 章华燕 编辑 黄俊嘉 在数据挖掘领域 经常会遇到的情况是挖掘出来的特征数据存在各种异常情况 如数据缺失 数据值异常 等 对于这些情况 如果不加以处理 那么会直接影响到最终挖掘模型建立后的使用效果 甚至是使得最终的模型失效 任务失败 所
  • 将matlab变量导入excel并生成行列标题

    1 将matlab里生成的变量导入到excel中 xlswrite 具体路径 data xlsx AG set 1 B1 k1 xlswrite 表格路径 变量名称 sheet1 数据显示的范围 2 为生成的表格指定行列标题 xlswrit
  • React的事件处理

    目录 一 React的事件处理 1 与DOM事件处理的不同之处 1 React事件的命名方式 小驼峰方式 DOM的命名方式是小写 2 事件处理函数是以对象的方式赋值 而不是以字符串的方式赋值 3 阻止默认事件的方式不同 2 React中事件
  • /PROC/MEMINFO之谜

    proc meminfo是了解Linux系统内存使用状况的主要接口 我们最常用的 free vmstat 等命令就是通过它获取数据的 proc meminfo所包含的信息比 free 等命令要丰富得多 然而真正理解它并不容易 比如我们知道
  • Rust- 结构体

    In Rust a struct short for structure is a custom data type that lets you name and package together multiple related valu
  • 2.5 SPPNet

    目录 2 5 SPPNet 2 5 1 SPP 的目的 2 5 2 SPP 架构 2 5 3 SPP 用于目标检测 2 5 4 候选区域映射 参考资料 2 5 SPPNet SPP Spatial Pyramid Pooling 空间金字塔
  • cpu调优

    1 大内存页 2 数据刷写频率 忍受多长时间丢失 越长越好 脏数据有可能把内存耗尽的危险 3 尽可能不把内存数据放到swap中 当物理内存使用到了6成有可能就开始使用swap了 跑tomcat hadoop python java 内程序尽
  • 《与韩荆州书》--李白经典求职信

    白闻天下谈士相聚而言曰 生不用封万户侯 但愿一识韩荆州 何令人之景慕 一至于此耶 岂不以有周公之风 躬吐握之事 使海内豪俊奔走而归之 一登龙门 则声誉十倍 所以龙盘凤逸之士 皆欲收名定价于君侯 愿君侯不以富贵而骄之 寒贱而忽之 则三千宾中有
  • 图解Windows10下如何更换Jupyter Notebook 内核Python版本(切换原始的python环境)

    问题描述 启动Jupyter Notebook之后它会自动加载原始的python环境 如下图所示 但是自己又在Anaconda中下载了新的虚拟环境 很多库都在这个虚拟环境中 那么如何让Jupyter Notebook加载自己的这个虚拟环境呢
  • python练习.一球从100米高度自由落下,每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?第10次反弹多高?

    high tour hei 100 for i in range 0 10 if i 0 tour append hei else tour append 2 hei hei 2 high append hei print 总高度 tour
  • redis单机,集群搭建教程

    环境准备 Linux 版本 Centos 7 0 2009 Redis版本 redis 5 0 3 tar gz 文章目录 一 redis是什么 二 单机搭建步骤 三 集群搭建步骤 在一台机子搭建一个伪集群 总结 一 redis是什么 通常
  • LaTex 加粗(加黑)的方式

    1 基本 LaTeX技巧458 关于LaTeX数学字体加粗 mathbf 会变为粗体 但也导致数学字母斜体形式的丢失 使用 amsmath package 的 boldmath 命令 boldmath f x y 3 x y y 2xy 7
  • Failed to initialize NVML: Driver/library version mismatch

    nvidia驱动安装之后 nvidia smi 报错 Driver library version mismatch 不重启系统的解决方法 查看系统日志 确定具体报错信息 dmesg tail 8598493 408944 NVRM API
  • Unity2018新功能抢鲜

    本文首发于 洪流学堂 微信公众号 洪流学堂 让你学Unity快人几步 洪流学堂公众号回复节点 获取ShaderGraph节点详解PDF文件 带目录 Shader一直是Unity开发者的一个难关 涉及到数学 图形学 shader语法等多个难题
  • oracle 导出指定表和导入

    导出之前要注意一个问题 版本的问题 所以导出的语句应该指定版本 版本应该是要导入这些表的数据库的版本 expdp user password sid tables table1 table2 file expdp2022111 dmp ve
  • LeetCode力扣热题一百·自我解法记录(JAVA版本·仅代码)

    1 两数之和 哈希表 题目链接 力扣 两数之和 简单 import java util HashMap class Solution public int twoSum int nums int target 创建哈希表 HashMap
  • JavaScript - 插入排序的两种方式

    插入排序1 新建一个新数组 循环遍历原始数据 把原始数组内的每一个逐个插入到新数组内 在插入的时候 按照一定的顺序插入 原始数组 var arr 9 2 5 3 7 6 4 1 8 准备一个新数组 var newarr 循环遍历原始数组 f
  • 大学生团体天梯赛(第六届)

    题目地址 天梯赛 include