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

2023-11-15

题目地址:天梯赛

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int main() {
    puts("To iterate is human, to recurse divine.");
    return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int a, b, c;
int main() {
    cin >> a >> b >> c;
    cout << a - b * c;
    return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
char s[6];
int y, m;
int main() {
	cin >> s;
	if(strlen(s) == 6) {
		cout << s[0] << s[1] << s[2] << s[3] << "-" << s[4] << s[5];
	} else {
		sscanf(s, "%2d%2d", &y, &m);
		if(y < 22) cout <<"20";
		else cout << "19";
		printf("%02d-%02d", y, m);
	}
    return 0;
}

在这里插入图片描述

#include <bits/stdc++.h>
using namespace std;
double n, m, k;
int main() {
	cin >> n >> m;
	while(n--) {
		cin >> k;
		if(k < m) printf("On Sale! %.1f\n", k);
	}
	return 0;
}

在这里插入图片描述

#include <bits/stdc++.h>
using namespace std;
int a[24], x;
int main() {
	for(int i = 0; i < 24; ++i) {
		cin >> a[i];
	}
	while(cin >> x) {
		if(x < 0 || x >= 24) return 0;
		cout << a[x] << " " << (a[x] > 50 ? "Yes" : "No") << endl;
	}
	return 0;
}

在这里插入图片描述

#include <bits/stdc++.h>
using namespace std;
int n, m;
string s, ans = "Wo AK le";
int main() {
	cin >> n >> m, getchar();
	for(int i = 0; i < n; ++i) {
		getline(cin, s);
		if(s.find("qiandao") == s.npos && s.find("easy") == s.npos) {
			--m;
			if(m < 0) ans = s; 
		}
	}
	cout << ans;
	return 0;
}

在这里插入图片描述

#include <bits/stdc++.h>
using namespace std;
int n, x;
map<int, int> mp;
int main() {
	cin >> n;
	while(n--) {
		cin >> x;
		++mp[x];
	}
	cout << mp.begin()->first << " " << mp.begin()->second << endl << mp.rbegin()->first << " " << mp.rbegin()->second;
	return 0;
}

在这里插入图片描述

#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
int a[N], n, x; 
int main() {
	cin >> a[0] >> a[1] >> n;
	for(int i = 0, j = 2;; ++i) {
		x = a[i] * a[i + 1];
		if(x > 9) a[j++] = x / 10, a[j++] = x % 10;
		else a[j++] = x;
		if(j >= n) {
			for(int i = 0; i < n; ++i) {
				cout << (i ? " " : "") << a[i];
			}
			return 0;			
		}
	}
	return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> mp;
int N, n, m, k, a, b, v, ans = INT_MAX, flag, cnt;
int f[205];
int main(){
	cin >> N >> m;
	while(m--) {
		cin >> a >> b >> v;
		mp.insert({{a, b}, v}), mp.insert({{b, a}, v});
	} 
	cin >> k;
	for(int i = 1; i <= k; ++i) {
		unordered_set<int> st;
		bool is_right = true;
		int res = 0, now = 0;
		cin >> n;
		for(int i = 0; i < n; ++i) {
			cin >> f[i];
			if(st.count(f[i])) is_right = false;
			st.emplace(f[i]);
		}
		if(!is_right || N != n) goto here;
		f[n++] = 0;
		for(int i = 0; i < n; ++i) {
			if(mp.count({now, f[i]})) res += mp[{now, f[i]}], now = f[i];
			else goto here;
		}
		++cnt;
		if(ans > res) flag = i, ans = res;
here:;
	}
	cout << cnt << endl << flag << " " << ans;
	return 0;
}

在这里插入图片描述
在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int n, m, s, x; 
char a;
stack<char> st;
queue<char> vt[105];
int main() {
	cin >> n >> m >> s;
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j) {
			cin >> a;
			vt[i].push(a); 
		}
	}
	while(cin >> x) {
		if(x == -1) {
			return 0;
		}
		if(!x) {
			if(st.empty()) continue;
			cout << st.top();
			st.pop();
		} else {
			if(vt[x - 1].empty()) continue;
			if(st.size() == s) {
				cout << st.top();
				st.pop();
			}
			st.push(vt[x - 1].front()), vt[x - 1].pop(); 
		}
	}
	return 0;
} 

在这里插入图片描述
在这里插入图片描述

#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5;
int n, k, x, ans, flag, cnt;
vector<int> from[N];
int f[N];
int dfs(int x) {
	if(f[x] != -1) return f[x];
	int maxx = 0;
	for(int i = 0; i < from[x].size(); ++i) {
		maxx = max(maxx, dfs(from[x][i]));
	}
	f[x] = maxx + 1;
	return f[x];
}
void print(int x) {
	if(cnt) cout << " ";
	++cnt, cout << x, k = N;
	for(int i = 0; i < from[x].size(); ++i) {
		if(f[from[x][i]] == f[x] - 1) k = min(k, from[x][i]);
	}
	if(k == N) return;
	print(k);
}
int main() {
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> k;
		for(int j = 0; j < k; ++j) {
			cin >> x;
			from[i].push_back(x);
		}
	}
	memset(f, -1, sizeof(f));
	for(int i = 0; i < n; ++i) {
		x = dfs(i);
		if(x > ans) {
			ans = x, flag = i;
		}
	}
	cout << ans << endl;
	print(flag);
	return 0;
}

在这里插入图片描述
在这里插入图片描述

#include <bits/stdc++.h>
using namespace std;
int n, m, x, cnt;
const int N = 1e4 + 5;
struct P{
	vector<int> vt;
	int sizes;
}p[N];
map<vector<int>, int> mp;
int main() {
	cin >> n >> m;
	for(int i = 0; i < n; ++i) {
		vector<int> now;
		for(int j = 0; j < m; ++j) {
			cin >> x;
			now.push_back(x);
		}
		++mp[now];
	}
	for(auto i : mp) {
		p[cnt].sizes = i.second, p[cnt++].vt = i.first;
	}
	sort(p, p + cnt, [](P A, P B){
		return A.sizes > B.sizes || A.sizes == B.sizes && A.vt < B.vt;
	});
	cout << cnt << endl;
	for(int i = 0; i < cnt; ++i) {
		cout << p[i].sizes;
		for(int j : p[i].vt) {
			cout << " " << j;
		}
		cout << endl;
	}
	return 0;
}

在这里插入图片描述
在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> a[N]; 
unordered_map<int, int> mp;
int n, m, k, x, now = 1;
int main() {
	cin >> n >> m;
	for(int i = 1; i <= n; ++i) {
		cin >> k;
		for(int j = 1; j <= k; ++j) {
			cin >> x; 
			a[i].push_back(x);
		}
	}
	while(m--) {
		cin >> k >> x;
		if(k == 0) now = a[now][x - 1];
		else if(k == 1) mp[x] = now, cout << now << endl;
		else now = mp[x];
	}
	cout << now;
	return 0;
}

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
int n, m, k, x;
int main() {
	cin >> n;
	vector<int> a(n), res;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	cin >> m;
	vector<vector<int>> b(m);
	for(int i = 0; i < m; ++i) {
		cin >> k, b[i].resize(k);
		for(int j = 0; j < k; ++j) {
			cin >> b[i][j];
		}
	}
	auto print = [&]() {
		for(int i = 0; i < (int)res.size(); ++i) {
			cout << (i ? " " : "") << res[i] + 1;
		}
	};
	function<void(int)> dfs = [&](int x) {
		if(x == n - 1) {
			print();
			exit(0);
		}
		for(int i = 0; i < m; ++i) {
			bool flag = true;
			for(int j = 0; j < b[i].size(); ++j) {
				if(b[i][j] != a[j + x]) {
					flag = false;
					break;
				}
			}
			if(flag) {
				res.push_back(i);
				dfs(x + b[i].size() - 1);
				res.pop_back();
			}	 
		}
	};
	for(int i = 0; i < m; ++i) {
		bool flag = true;
		for(int j = 0; j < b[i].size(); ++j) {
			if(b[i][j] != a[j]) {
				flag = false;
				break;
			}
		}
		if(flag) {
			res.push_back(i);
			dfs(b[i].size() - 1);
			res.pop_back();
		} 
	}
	return 0;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

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

  • linux笔记之初次接触信号

    一 关于信号概念 1 信号是Linux所使用的进程间通信的最古老的方式 它是在软件层次上对中断机制的一种模拟 是一种异步通信的方式 一个完整的信号周期包括三个部分 信号的产生 信号在进程中的注册 信号在进程中的注销 执行信号处理函数 如下图
  • Linux系统之部署Dailynotes个人笔记管理工具

    Linux系统之部署Dailynotes个人笔记管理工具 一 Dailynotes介绍 二 本地环境介绍 2 1 本地环境规划 2 2 本次实践介绍 三 检查本地环境 3 1 检查本地操作系统版本 3 2 检查系统内核版本 3 3 检查本地
  • Python中insert用法详解!

    Python中insert用法是什么 这篇文章为大家详细的讲解一下Python中insert用法 并附带实战案例 希望能够给你们带来帮助 描述 insert 函数用于将指定对象插入列表的指定位置 语法 inser 方法语法 list ins
  • 华为云云耀云服务器L实例评测|Linux系统之安装Tomcat

    华为云云耀云服务器L实例评测 Linux系统之安装Tomcat 一 云耀云服务器L实例介绍 1 1 云耀云服务器L实例简介 1 2 云耀云服务器L实例特点 二 Tomcat介绍 2 1 Tomcat简介 2 2 Tomcat特点 三 本次实

随机推荐

  • 可视化技巧:分类问题中的决策面画法 (直观理解plt.contour的用法)

    摘要 通过分类问题中决策面的绘制过程直观理解matplotlib中contour的用法 主要包括对 np meshgrid 和plt contour的直观理解 前言 分类问题中 我们习惯用2维的dmeo做例子 验证算法的有效性 直观的评价方
  • css实现随机颜色,CSS3 一个显示随机颜色的动画

    CSS 语言 CSSSCSS 确定 html body background webkit linear gradient top fff dcf background linear gradient to bottom fff dcf h
  • upload-labs-master靶场 Pass06-10通关秘诀(详解版)

    关数 通关特征 PASS 06 大小写绕过上传 关卡分析 有些程序编写上传点过滤时会过滤常见后缀 黑名单 如php asp aspx jsp phtml等 如果为对上传 后缀进行小写转换 那么我们即可通过文件后缀名大小写方式进行绕过上传we
  • 数据结构之线性结构

    数据结构是计算机存储 组织数据的方式 数据结构是指相互之间存在一种或多种特定关系的数据元素的集合 通常情况下 精心选择的数据结构可以带来更高的运行或者存储效率 数据结构往往同高效的检索算法和索引技术有关 常见的数据结构可分为 线性结构 树形
  • 用docker借助deepo镜像训练深度学习模型

    这里写自定义目录标题 用docker借助deepo镜像训练深度学习模型 Deepo简介 docker hub 地址 安装步骤 运行 用docker借助deepo镜像训练深度学习模型 Deepo简介 deepo是我从网上了解的一个比较全的深度
  • 回想过去几年的编程生活

    17年 我从一所普通的二本学校毕业 抱着对未来无限憧憬的希望踏上社会 3年初中 3年高中 4年大学 一步一步 努力奋斗 终于要开始挣钱了 终于可以独立了 仿佛美好的一切都会来的 记得是16年的是12月 大四上学期 结束 我迫不及待的找了一份
  • (实习)基线检测时遇到的问题

    首先要先清楚什么是基线检测 安全基线其实是系统最低安全要求的配置 常见的安全基线配置标准有ISO270001 等级保护2 0等 企业也可以建立自己的标准 检测的内容 分为三个方面 1 系统存在的安全漏洞 2 系统配置的脆弱性 3 系统状态的
  • ★动态规划(DP算法)详解

    什么是动态规划 动态规划 百度百科 内容太多了不作介绍 重点部分是无后效性 重叠子问题 最优子结构 问S gt P1和S gt P2有多少种路径数 毫无疑问可以先从S开始深搜两次 S gt P1和S gt P2找出所有路径数 但是当这个图足
  • linux上使用libreoffice对文件类型转换

    目录 libreoffice下载与安装 使用 常见问题 libreoffice下载与安装 1 手动下载 https www libreoffice org download download libreoffice type deb x86
  • JVM类加载机制以及类缓存问题的处理

    当一个java项目启动的时候 JVM会找到main方法 根据对象之间的调用来对class文件和所引用的jar包中的class文件进行加载 其步骤分为加载 验证 准备 解析 初始化 使用和卸载 方法区中开辟内存来存储类的运行时数据结构 包括静
  • 安装cvxpy之后,报错The solver GLPK_MI is not installed

    安装cvxpy之后用的时候 报错The solver GLPK MI is not installed 这边我们可以用以下代码查看已经安装的下载器 print cvxpy installed solvers 在安装个cvxopt即可 pip
  • 基于SpringBoot的财务管理系统

    末尾获取源码 开发语言 Java Java开发工具 JDK1 8 后端框架 SpringBoot 前端 Vue 数据库 MySQL5 7和Navicat管理工具结合 服务器 Tomcat8 5 开发软件 IDEA Eclipse 是否Mav
  • 解决:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure(真实有效)

    数据库连接失败 一 例如我在SpringBoot项目中使用了阿里的数据库连接池Driud 有次在启动的时候 会报这样的错 Caused by com mysql cj exceptions CJCommunicationsException
  • 艺术品拍卖爬虫:使用Python抓取艺术品拍卖网站上的拍卖信息与成交价格

    目录 第2部分 爬取艺术品拍卖网站数据 2 1 确定目标网站 2 2 获取页面内容 2 3 解析网页内容
  • 学习编程有必要做笔记吗?

    小编发现W3Cschool的程序员很喜欢记笔记 桌面永远挂着个笔记软件 笔记本也写的密密麻麻的 那么做编程真的有必要做笔记吗 怎么记呢 一起来看下知乎网友怎么说 花生PeA 记不记笔记看情况 比如题主学的HTML CSS PHP 已经有十分
  • 行内元素的默认的横向边距与纵向边距

    行内元素在渲染是会默认添加右侧和底部边距 如果在多个图片排列时这种情况就比较明显 当我们需要在布局上完全无边距的时候就需要去除这些编剧 去除方法就是 在单元元素上添加下面对应的属性去除边距 去除横向边距 x noSpace font siz
  • 梯度下降法解决线性回归

    用梯度下降的优化方法来快速解决线性回归问题 import tensorflow as tf import numpy as np import matplotlib pyplot as plt import os os environ TF
  • 560. Subarray Sum Equals K

    Given an array of integers and an integer k you need to find the total number of continuous subarrays whose sum equals t
  • Java服务器授权+授权工具部分代码及思路

    目标 项目部署到服务器上 需要当前服务器授权后才能正常访问 控制项目授权日期 某终端 通道 授权数量 用户登录访问菜单权限 注 授权端 授权工具在自己手里 控制授权 在此我称之为授权工具 被授权端 jar包部署的服务器端 在此我称之为服务器
  • 大学生团体天梯赛(第十届)

    题目地址 天梯赛 include