ACM/ICPC 2018亚洲区预选赛北京网络赛 B.Tomb Raider(暴力)

ICPC-2022网络赛第二场 首先, 对于一个满足条件的区间, 若确定最小值x , 那么该区间内的数字一定是 [x ~ x + len - 1] , 也就是方案数 = len!排完序后访问, l 一定是刚好包括的, 如果 r 也被包括了, 那么就是这个区间, 如果r 没有被包括, 就pop, 直到找到刚好满足的。给一个长度为n的字符串 在字符串内只有 I,C,P 三个字符,有 Q 次询问,每次询问某两个区间内为ICPC的子序列有多少个?第i行, 是将序列 a[1…是 该题的一个单位元, 也就是说, 1%p, 10%p , … 阅读详情

Lara Croft, the fiercely independent daughter of a missing adventurer, must push herself beyond her limits when she discovers the island where her father disappeared. In this mysterious island, Lara finds a tomb with a very heavy door. To open the door, Lara must input the password at the stone keyboard on the door. But what is the password? After reading the research notes written in her father’s notebook, Lara finds out that the key is on the statue beside the door.

The statue is wearing many arm rings on which some letters are carved. So there is a string on each ring. Because the letters are carved on a circle and the spaces between any adjacent letters are all equal, any letter can be the starting letter of the string. The longest common subsequence (let’s call it “LCS”) of the strings on all rings is the password. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.

For example, there are two strings on two arm rings: s1 = “abcdefg” and s2 = “zaxcdkgb”. Then “acdg” is a LCS if you consider ‘a’ as the starting letter of s1, and consider ‘z’ or ‘a’ as the starting letter of s2. But if you consider ‘d’ as the starting letter of s1 and s2, you can get “dgac” as a LCS. If there are more than one LCS, the password is the one which is the smallest in lexicographical order.

Please find the password for Lara.

输入
There are no more than 10 test cases
In each case:
The first line is an integer n, meaning there are n (0 < n ≤ 10) arm rings.

Then n lines follow. Each line is a string on an arm ring consisting of only lowercase letters. The length of the string is no more than 8.

输出
For each case, print the password. If there is no LCS, print 0 instead.

求n个循环串的lcs。
看起来像个神级问题,但是由于n只有10,字符串长度只有8,所以暴力上,枚举出每个循环串的所有子序列,然后合并集合,取字典序最小。

至于循环串,用经典的把s变成ss就能解决,然后dfs串枚举,注意扩大成ss之后枚举区间应该在起始位置到起始位置+s的长度。

ac代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, len, idx;
string s;
set<string> st[10];

void dfs(string m, int fa, int start) {
	st[idx].insert(m);
	for(int i = start + 1; i < s.length() && i < fa + len; i++) {
		dfs(m + s[i], fa, i);
	}
}

int main() {
	ios::sync_with_stdio(0);
	while(cin >> n) {
		for(idx = 0; idx < n; idx++) {
			cin >> s;
			len = s.length();
			s = s + s;
			for(int i = 0; i < len; i++) {
				dfs(s.substr(i, 1), i, i);
			}
		}
		string ans = "0";
		for(auto i : st[0]) {
			bool flag = 0;
			for(int j = 1; j < n; j++) {
				if(!st[j].count(i)) {
					flag = 1;
					break;
				}
			}
			if(!flag) {
				if(ans[0] == '0'){
					ans = i;
					continue;
				}
				if(i.length() > ans.length()) {
					ans = i;
				} else if(i.length() == ans.length()) {
					ans = min(ans, i);
				}
			}
		}
		for(int i = 0; i < n; i++) {
			st[i].clear();
		}
		cout << ans << endl;
	}
	return 0;
}
Moving On 第 44 届 ACM/ICPC 亚洲区域赛(银川)网络赛 Firdaws and Fatinah are living in a country with nnn cities, numbered from 111 to nnn. Each city has a risk of kidnapping or robbery. Firdaws's home locates in the city uuu, and Fatinah's home locate... 阅读详情

相关推荐

密码学小白必看:三大顶级会议论文下载与阅读指南(附完整资源链接)

本文为密码学初学者提供了系统获取和阅读三大顶级会议(Crypto、Eurocrypt、Asiacrypt)论文的实战指南。详细介绍了通过IACR官方渠道、ePrint预印本等权威资源免费下载论文的方法,并分享了高效筛选、精读核心章节及构建个人知识体系的具体策略,帮助读者快速切入密码学研究前沿。

weixin_28363123的博客 424

ACM-ICPC2018北京网络赛 Tomb Raider(暴力)

题目2 : Tomb Raider 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Lara Croft, the fiercely independent daughter of a missing adventurer, must push herself beyond her limits when she discovers...

weixin_30651273的博客 239

node20.5.0安装sqlite3报错

node20.5.0安装sqlite3报错

徐同保的专栏 777

ACM/ICPC 2018亚洲区预选赛北京赛站网络赛

A Saving Tang Monk II k layers problem #include &amp;amp;amp;lt;bits/stdc++.h&amp;amp;amp;gt; using namespace std; #define FORP(i,a,b) for(int i=a;i&amp;amp;amp;lt;=b;++i) int n,m; bool check(int x,int y){ return x&amp;amp;amp;

CODER的博客 927

手把手教你用Cursor + 自定义MCP工具链,让AI帮你搞定App逆向(附adb-mcp/frida-mcp源码)

本文详细介绍了如何利用Cursor IDE与自定义MCP工具链构建AI驱动的App逆向工作流,涵盖adb-mcp和frida-mcp的源码实现与实战应用。通过自然语言指令,AI可自动化完成设备控制、动态Hook和数据分析,显著提升移动安全测试效率。适合安全研究人员和开发者快速掌握智能逆向技术。

weixin_33737134的博客 1312

STM32G070xx将Flash页分块方式存储,固定数据块存储,实现一次擦除多次写入

本例程使用STM32G070xx芯片,Flash大小128KB,Flash每页(2048字节)写满后再擦除。操作存储区分为64块,每块32字节,即写满64次擦除一次;标定存储区分为16块,每块128字节,即写满16次擦除一次,每个存储区的块都有各自的头部标记

RaphaelCeo的博客 1551

ACM/ICPC 2018亚洲区预选赛北京赛站网络赛 A(bfs)

传送门 题面: #1828 : Saving Tang Monk II 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 《Journey to the West》(also 《Monkey》) is one of the Four Great Classical Novels of Chinese literature. It was written by...

Chen.Jr的博客 951

Python爬虫实战:巧用HEAD请求和Cookie令牌绕过沃尔玛反爬(附完整代码)

本文详细介绍了如何利用Python爬虫技术,通过HEAD请求和Cookie令牌绕过沃尔玛的反爬机制。文章深入解析了人机验证系统的运作原理,并提供了完整的工程化实现代码,包括令牌池设计、高并发架构和异常处理策略,帮助开发者高效采集电商数据。

weixin_29046035的博客 1021

ACM/ICPC 2018亚洲区预选赛北京赛站网络赛 B. Tomb Raider(暴力枚举)

题目链接:hihoCoder #1829 : Tomb Raider 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Lara Croft, the fiercely independent daughter of a missing adventurer, must push herself beyond her limits when she discov...

yz467796454的博客 259

GEE APP:基于GEE的红树林监测平台

本文将介绍如何利用Google Earth Engine平台,结合Landsat系列卫星影像和SRTM高程数据,实现红树林分布的动态监测与变化分析。

此星光明博客 163

RK3588 buildroot 制作的系统增加 docker 支持

RK3588 使用buildroot制作的系统添加 docker 和 docker-compose 的功能

荻夜的博客 1572

ACM/ICPC 2018亚洲区预选赛北京赛站网络赛 B. Tomb Raider

题解 给你n个串 这n个串都看作一个环 问n个串的最长公共子序列(不连续) 输出字典序最小的一个 暴力枚举第一个串的子序列(最多2^8个) 然后用string和rotate暴力尝试答案是否正确 最后找字典序最小 注意只有一个串的时候也需要找字典序最小 AC代码 #include &lt;stdio.h&gt; #include &lt;bits/stdc++.h&gt; using namespa...

CaprYang的博客 570

VI4302 1D dToF Sensor助力无人机定高避障:一场前所未有的飞行体验

另外,传感器因测量精度不够,产生的高度信息误差,会导致无人机无法精确定高,影响飞行稳定性和安全降落。芯视界于2022年发布的全新一代基于单光子探测技术的dToF激光雷达传感器芯片-VI4302,采用单电源低功耗系统,实现高性能测距、高稳定性,同时具备极强抗阳光能力以及兼容性等强大优势。无人机可以根据传感器提供的信息,快速调整飞行路径,避开潜在的障碍物,确保平稳的飞行。VI4302 1D dToF Sensor能够以极高的精度测量物体与无人机之间的距离,实现毫米级别的测量精度。⭐ 体型小巧,灵敏度高。

致力于lidar应用开发 629

ACM/ICPC 2018亚洲区预选赛北京赛站网络赛 Tomb Raider

时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Lara Croft, the fiercely independent daughter of a missing adventurer, must push herself beyond her limits when she discovers the island where her father dis...

liuyishou 266

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

ACM/ICPC 2018亚洲区预选赛北京赛站网络赛 B Tomb Raider 【二进制枚举】

任意门:http://hihocoder.com/problemset/problem/1829 Tomb Raider 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Lara Croft, the fiercely independent daughter of a missing adventurer, must push herself...

weixin_30872867的博客 191

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

ACM/ICPC 2018亚洲区预选赛北京赛站网络赛 B. Tomb Raider(二进制枚举)

传送门 题意:给n个字符串,首尾相连,求最长公共子序列,若答案多个,输出字典序最小的 思路:暴力把每个字符串的每个子序列放入map(要记得不能重复),出现n次的就是公共的子序列,符合条件的公共子序列都放入vector,最后排序,得到最长的字典序最小的那个 就是答案 #include &lt;bits/stdc++.h&gt; using namespace std; map&lt;stri...

sugarbliss 443

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

ACM/ICPC 2018亚洲区预选赛北京赛站网络赛 hihocoder #1829 : Tomb Raider(模拟)

                                             题目2 : Tomb Raider 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Lara Croft, the fiercely independent daughter of a missing adventurer, must push herself beyon...

Amove 709

ACM/ICPC 2018亚洲区预选赛北京赛站网络赛 B. Tomb Raider(二进制枚举)

  题目链接:http://hihocoder.com/problemset/problem/1829         题意是在n个环形的(首尾相连)字符串中找最长公共子序列。         在比赛的时候因为数据范围不大,想着去一个一个的暴力把每个串以每个字符为首字符的串都存起来然后去求他们的lcs,然后发现求n个字符串的lcs是没法往下传递的,所以就不会了...         这道题...

Charles_Zaqdt的博客 503

Tomb Raider (暴力枚举)

Lara Croft, the fiercely independent daughter of a missing adventurer, must push herself beyond her limits when she discovers the island where her father disappeared. In this mysterious island, Lara f...

自渡的博客 763

ACM/ICPC 2018亚洲区预选赛北京赛站网络赛-B:Tomb Raider(二进制枚举)

时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Lara Croft, the fiercely independent daughter of a missing adventurer, must push herself beyond her limits when she discovers the island wher...

weixin_33979203的博客 193

ICPC2021第一场网络预选赛A题

ICPC2021第一场网络预选赛A题 A题题意大概就是有n台机器,有m个待运行的程序,输入会给定机器数量,还有每个程序的到达时间和运行时间,求所有处理程序最多的机器,按机器下标排输出。 ps(第i个程序到达时会从第i%n台机器开始寻找第一台空闲机器,那么就是从i%n - n 寻找第一台空闲机器,如果没有空闲机器,就从1 - (i%n - 1)寻找,若所有机器都不空闲,则此程序丢弃) 解题思路:从题意我们可以解析出每个程序其实是在i%n - n 和1 - (i%n - 1) 两个区间寻找第一台空闲机器,

weixin_47278759的博客 1090

小米ICPC预选赛-A:数论,dp

题目大意: 给你一个序列a1,...,ana_1,...,a_na1​,...,an​.让你从里面选出一个子集SSS,使得子集中任意两个数都互为倍数.求最大子集.(n≤1e5,ai≤1e7n \leq 1e5,a_i\leq1e7n≤1e5,ai​≤1e7). 题目思路: 首先,本题的弱化版:https://leetcode-cn.com/problems/largest-divisible-subset/solution/。 整除关系具有传递性,所以任意两个数成倍数关系不妨转化为:【对子集SSS排序后相邻

qq_35577488的博客 262

2018北京ICPC B. Heshen's Account Book(模拟)

  B : Heshen's Account Book 时间限制:1000ms  单点时限:1000ms  内存限制:512MB 描述 Heshen was an official of the Qing dynasty. He made a fortune which could be comparable to a whole country's wealth by corruptio...

加载中... 1145

2019年 ICPC亚洲区预赛(上海赛区)总结

首先,我要说,我输了,输给了自己的无知,输给了自己的心态与实力。 上海区域赛,打铁而归,最终还是没有比过自己SLG的朋友。要说什么呢?实力的差距,还是说给自己的失败找借口?不能进入金牌区,为什么铜牌区还进不去,自己所有的骄傲,所有的成就似乎被一场比赛击溃。原来自己只是一叶障目不见泰山。 热身赛,知道了位运算的优化技巧,N/32。 2^N枚举,这是跟CDX的差距。 这场比赛,差多少呢,差一脚,...

日拱一卒,功不唐捐 5590
上一篇: HDU - 2586 How far away ?(最近公共祖先)
下一篇: 2017秦皇岛CCPC E.String of CCPC(暴力)
Cymbals
博客等级 码龄9年 45粉丝 157原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值