POJ 3087 Shuffle'm Up(模拟)

如何降低 Claude Code 封号风险:实用指南 本文针对 Claude Code 用户频繁遭遇账号封禁的问题,提供了一套经过实战验证的解决方案。通过分析封号的根本原因——共享VPN导致的IP异常标记,文章详细介绍了如何通过"独立服务器+中转服务+环境配置"三步走策略,显著降低封号风险。 阅读详情

Description

A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containing C chips. Each stack may contain chips of several different colors.

The actual shuffle operation is performed by interleaving a chip from S1 with a chip from S2 as shown below for C = 5:

The single resultant stack, S12, contains 2 * C chips. The bottommost chip of S12 is the bottommost chip from S2. On top of that chip, is the bottommost chip from S1. The interleaving process continues taking the 2nd chip from the bottom of S2 and placing that on S12, followed by the 2nd chip from the bottom of S1 and so on until the topmost chip from S1 is placed on top of S12.

After the shuffle operation, S12 is split into 2 new stacks by taking the bottommost C chips from S12 to form a new S1 and the topmost C chips from S12 to form a new S2. The shuffle operation may then be repeated to form a new S12.

For this problem, you will write a program to determine if a particular resultant stack S12 can be formed by shuffling two stacks some number of times.

Input

The first line of input contains a single integer N, (1 ≤ N ≤ 1000) which is the number of datasets that follow.

Each dataset consists of four lines of input. The first line of a dataset specifies an integer C, (1 ≤ C ≤ 100) which is the number of chips in each initial stack (S1 and S2). The second line of each dataset specifies the colors of each of the C chips in stack S1, starting with the bottommost chip. The third line of each dataset specifies the colors of each of the C chips in stack S2 starting with the bottommost chip. Colors are expressed as a single uppercase letter (A through H). There are no blanks or separators between the chip colors. The fourth line of each dataset contains 2 * C uppercase letters (A through H), representing the colors of the desired result of the shuffling of S1 and S2 zero or more times. The bottommost chip’s color is specified first.

Output

Output for each dataset consists of a single line that displays the dataset number (1 though N), a space, and an integer value which is the minimum number of shuffle operations required to get the desired resultant stack. If the desired result can not be reached using the input for the dataset, display the value negative 1 (−1) for the number of shuffle operations.

Sample Input

2
4
AHAH
HAHA
HHAAAAHH
3
CDE
CDE
EEDDCC

Sample Output

1 2
2 -1

Source




题意: 给你a,b,c三堆牌,b放一张,a放一张,放成一堆新的牌,这样看能不能放成c,如果不能,那么底下的牌(数量已知)为a,上面为b,继续重复,

如果能放成功,输出次数,否则-1


模拟题,解释在代码



#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

string ss,e,s;
int ans,len;

void bfs()
{
    if(ans&&s==ss) //如果和第一次想同,不可能成功,死循环
        return ;

    if(s==e)  //放成功了
        return ;

    ++ans; //仿牌次数增加

    int i,j;
    string a,b;

    a=b="";
    for(i=0;i<len;i++)
        a+=s[i];   

    for(;i<len*2;i++)
        b+=s[i];

     s="";
    for(i=0;i<len;i++)
    {
        s+=b[i]; //先b
        s+=a[i];  //后a
    }

    bfs();
}

int main()
{
    int t,ca=0;
    int i,j;
    string a,b;

    scanf("%d",&t);
    while(t--)
    {
       cin>>len>>b>>a>>e; //不好意思,我是输入的b,a
       ans=0;
       s="";
       for(i=0;i<len;i++)  //这是第一次放牌,所以后面输出ans+1
       {
           s+=a[i];
           s+=b[i];
       }

        ss=s;
        bfs();

        if(s==e)
            printf("%d %d\n",++ca,ans+1);
        else
            printf("%d -1\n",++ca);
    }
    return 0;
}








轴承故障诊断领域的论文到底有多水 这个是最让人困惑的,就好像你说自己证明了某个方法更好,但是你却没有交代自己怎么做的,或者说你交代的过程有外行话或者逻辑上的缺陷,但是你就这么给出个结果完事了。由于自己没有足够大的学术交流圈子,为了尽量避免误判,我在原来13篇论文的基础上又读了18篇,这些论文至少都出自中文核心,有一些还有EI的title,事实上近几年能找到的文章也不算多,这些基本能说明问题了。当然,还有更多细节,比如说损失函数你得交代吧,模型超参数得介绍全吧,至少数据集是哪个工况下的得说吧,当你想复现这些论文,关注点在这些地方的时候。 阅读详情

相关推荐

swupdate-签名验证

swupdate加密部分具体在中可以查看。

qq_28219531的博客 1148

[kuangbin]专题一 简单搜索 Shuffle'm Up POJ - 3087【BFS】

【题目描述】 A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containing C ch...

inv0ker的博客 256

56-FMC连接器电路设计

FMC连接器电路设计

weixin_66510961的博客 4723

3087_Shuffle'm Up

Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips,S1andS2, each stack co...

weixin_30558305的博客 249

Isaac Gym摄像头数据获取全攻略:从CPU到GPU,教你实时显示RGB与深度图

本文详细介绍了在Isaac Gym中获取摄像头数据的两种高效方案:CPU模式与GPU张量模式。通过实战代码示例,展示了从摄像头配置、数据获取到实时可视化RGB与深度图的全流程,帮助开发者优化机器人仿真与计算机视觉应用的性能。特别强调了GPU模式下的零拷贝访问与张量运算优势,适用于需要低延迟处理的场景。

weixin_29056701的博客 387

Halcon深度学习实战:基于异常值检测的工业缺陷精准识别方案

本文详细介绍了Halcon深度学习中的异常值检测技术在工业缺陷识别中的应用。该方法仅需少量正常样本即可训练,能有效应对未知、多变的缺陷类型,显著降低项目启动门槛。文章提供了从数据准备、模型训练、参数调优到产线部署的完整实战指南,并分享了关键的性能优化与避坑经验。

weixin_29042035的博客 243

解题报告——poj3087

poj3087 题目链接: https://vjudge.net/problem/POJ-3087 题目类型:暴力模拟+字符串 字符串的题最好还是用string,比char数组方便很多 sacnf读入字符会读入回车,需要用getchar()消除 多个用例的情况下注意清空 提交记录 第一次CE,因为poj不支持c++11所以不能使用哈希表 第一次WA,加了一个清空字符数组e的语句 第二次WA,修改了第47行的memcpy,对于memcpy函数第三个参数是要复制过去的字节大小,要复制4个int就填4*si

smallEdward的博客 464

零基础入门simulink建模仿真--基于Simulink的QPSK调制与解调仿真建模示例

QPSK是一种相位调制技术,将两个比特映射到一个符号上,每个符号对应四个可能的相位之一(0°、90°、180°、270°)。通过Simulink,我们可以通过模块化的建模方式实现QPSK的调制和解调过程,并观察信号在信道中的传输效果。通过本指南,我们介绍了如何基于Simulink搭建一个完整的QPSK调制与解调仿真模型,并进行仿真和性能评估。背景介绍:理解QPSK调制与解调的基本原理及其应用。所需工具和环境:列出进行QPSK仿真所需的工具和环境。步骤详解。

amy_mhd的博客 1308

POJ - 3087 (Shuffle'm Up)

题意:首先设定一次转换,即图中 s1 和 s2 组成的 s12 ,下一轮 s12 的前半部分又成为了新的 s1,后半部分又成为了新的 s2; 现在给出 原始的 s1 和 s2 以及目标的 s12,问得经过多少轮转换之后,才可以 s1 和 s2 才可以组成目标的 s12,若永远不能则输出-1; 分析:暴力模拟转换过程就行了,用string操作会比较方便,然后用 set 记录中间达到过的...

Joker & Liar的博客 231

【时时三省】tessy 进入调试模式 教程

山不在高,有仙则名。水不在深,有龙则灵。----优快云 时时三省。

时时三省的博客 771

《YOLO11魔术师专栏》专栏介绍 & 专栏目录

【原创自研模块】【多组合点优化】【注意力机制】【主干篇】【neck优化】【卷积魔改】 【block&多尺度融合结合】【损失&IOU优化】【上下采样优化】【小目标性能提升】【前沿论文分享】【训练实战篇】

①答疑群聊服务;②YOLO大模型知识问答系统;③计算机视觉论文生成智能体; 1万+

Shuffle‘m Up(模拟>bfs)

Shuffle’m Up 题意:t组输入,先输入一个c表示长度,然后输入s1,s2长度都是c,然后再有一个2*c长度字符串,现在操作,两个短的字符串s2里先从头拿一个,然后s1交叉放置,合并后的字符串是否等于给出的长字符串,若不是的话,就是合成的前c个是新的s1,后c个是新的s2,反复操作,最少几步可以得到给定长字符串。 思路:bfs。然后就是跟题目描述一样的操作。 代码 #include<cstdio> #include<iostream> #include<cstring&

Celavia_yu的博客 291

结构力学本构模型:复合材料模型:复合材料热力学行为技术教程_2024-08-07_06-54-53.Tex

热塑性复合材料是一种由热塑性树脂基体和增强纤维组成的复合材料。与热固性复合材料不同,热塑性复合材料在加热时可以软化,冷却时硬化,这一过程可以重复进行,因此它们具有可回收和可再加工的特性。热塑性树脂,如聚酰胺(尼龙)、聚碳酸酯、聚醚醚酮(PEEK)等,与碳纤维、玻璃纤维等增强材料结合,可以制备出具有高强度、高刚度和良好耐热性的复合材料。热粘弹性理论是研究材料在温度变化和时间依赖性载荷作用下的变形和应力响应。复合材料,由于其独特的微观结构,展现出复杂的热粘弹性行为。

808

POJ.3087 Shuffle'm Up (模拟)

POJ.3087 Shuffle’m Up (模拟)题意分析给定两个长度为len的字符串s1和s2, 接着给出一个长度为len*2的字符串s12。将字符串s1和s2通过一定的变换变成s12,找到变换次数变换规则如下:假设s1=12345,s2=67890变换后的序列 s=6172839405如果s和s12完全相等那么输出变换次数如果不完全相等,s的前半部分作为s1,后半部分作为s2,重复上述过程。直

Pengwill's Blog 266

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

【POJ 3087 --- Shuffle'm Up】模拟

【POJ 3087 --- Shuffle'm Up】模拟 题目来源:点击进入【POJ 3087 — Shuffle’m Up】 Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting...

来日浅谈的博客 556

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

【Poj 3087 】 Shuffle'm Up 模拟

Shuffle’m Up Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8564 Accepted: 3932DescriptionA common pastime for poker players at a poker table is to shuffle stacks of chips. Shuff

ATOD 1146

【题解】POJ - 3087 Shuffle'm Up 模拟

题目链接:http://poj.org/problem?id=3087 这是做kuangbin搜索专题遇到的,然后现在还是不会搜索,那就模拟吧 根据题目模拟,跳出循环的条件是s1数组出现了循环(证明永远不会得出s12) ac代码: #include<cstdio> #include<iostream> #include<cstring> using namesp...

替这位空想家惊讶 151

Shuffle'm Up POJ - 3087 模拟

一、内容 题意:给定2个字符串s1,s2,将2个字符串进行重组成S,规则是S2最下面拿一个,S1最下面拿1个,直到所有块都用完。 二、思路 用map记录下S串结果,若以前访问过这个串代表不可能有结果直接返回-1。 然后就是模拟重组串的过程。 三、代码 #include <cstdio> #include <iostream> #include <cstring&g...

Tizzi的博客 814

POJ3087 Shuffle'm Up 模拟

Shuffle’m Up Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16500 Accepted: 7502 Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling ...

DouglasConnor的博客 303

poj 3087——Shuffle'm Up (模拟)

A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips,S1andS2, each stack containingCchips. Ea...

red_red_red的博客 161

POJ 3087 Shuffle'm Up(模拟)

Shuffle'm Up Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7404   Accepted: 3421 Description A common pastime for poker players at a poker table is to shuf

叶孤心的专栏 1293

poj3087 Shuffle'm Up(模拟)

Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips,S1andS2, each stack containin...

邵光亮的博客 648

poj 3087 Shuffle'm Up 模拟

Shuffle'm Up Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7341   Accepted: 3396 Description A common pastime for poker players at a poker table is to sh

呼,是出一口气;吸,是争一口气! 523

poj3087 Shuffle'm Up 模拟

Shuffle'm Up Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10039   Accepted: 4648 Description A common pastime for poker players at a poker table is to s

kyoma的博客 389

POJ 3087 Shuffle'm Up(模拟)

题意 给两堆牌s1,s2交给你洗 每堆有c张 每次洗牌得到s12 其中s2的最下面一张在s12的最下面一张然后按顺序一张s1一张s2 洗好之后可以把s12下面的c张做s1 上面的c张做s2 求多少次洗牌之后可以得到输入给你的串s 不能得到输出-1 简单模拟 s1+s2!=s就一直洗牌 如果回到初始状态都没得到s就不会得到s了 得到s就可以输出洗牌次数了

Good morning,good afternoon and good night 1135

POJ 3087 Shuffle'm Up(模拟+读题)

POJ 3087 http://poj.org/problem?id=3087 A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1...

夏日蹲坑的博客 291

[模拟]POJ 3087 Shuffle'm up

Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack contain

童凌的技术博客 496
上一篇: HDU 2614 Beat (dfs)
下一篇: HDU 1338 Game Prediction 贪心
左眼皮跳跳~
博客等级 码龄13年 17粉丝 400原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值