POJ3087 Shuffle'm Up(模拟)
题目链接。
AC代码如下;
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <ctype.h>
#include <set> using namespace std; const int maxn = +; int main() {
int T, n, cn; bool flag;
char s1[maxn], s2[maxn], s3[maxn], s[maxn]; scanf("%d", &T); for(int kase=; kase<=T; kase++) {
set<string> st;
cn = ; flag = true; scanf("%d", &n); scanf("%s%s%s", s1, s2, s3); while(true) {
cn++;
for(int i=; i<n; i++) {
s[*i] = s2[i];
s[*i+] = s1[i];
}
s[*n] = '\0'; if(strcmp(s, s3) == ) {
break;
} if(st.count(s) != ) {
flag = false;
break;
} st.insert(s); for(int i=; i<n; i++) {
s1[i] = s[i];
} for(int i=n; i<*n; i++) {
s2[i-n] = s[i];
} s1[n] = s2[n] = '\0';
} printf("%d ", kase);
if(flag) printf("%d\n", cn);
else printf("-1\n");
} return ;
}
POJ3087 Shuffle'm Up(模拟)的更多相关文章
- POJ3087:Shuffle'm Up(模拟)
http://poj.org/problem?id=3087 Description A common pastime for poker players at a poker table is to ...
- poj3087 Shuffle'm Up(模拟)
Shuffle'm Up Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10766 Accepted: 4976 Des ...
- POJ-3087 Shuffle'm Up (模拟)
Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuff ...
- POJ3087 Shuffle'm Up 简单模拟
题意:就是给你两副扑克,然后一张盖一张洗牌,不断重复这个过程,看能不能达到目标的扑克顺序 分析:然后就模拟下,-1的情况就是有循环节 #include<cstdio> #include&l ...
- 【POJ - 3087】Shuffle'm Up(模拟)
Shuffle'm Up 直接写中文了 Descriptions: 给定两个长度为len的字符串s1和s2, 接着给出一个长度为len*2的字符串s12. 将字符串s1和s2通过一定的变换变成s12, ...
- poj 3087 Shuffle'm Up (模拟过程)
Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuff ...
- POJ3087 Shuffle'm Up —— 打表找规律 / map判重
题目链接:http://poj.org/problem?id=3087 Shuffle'm Up Time Limit: 1000MS Memory Limit: 65536K Total Sub ...
- poj3087 Shuffle'm Up
Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuff ...
- POJ 3078 - Shuffle'm Up - [模拟题]
题目链接:http://poj.org/problem?id=3087 Description A common pastime for poker players at a poker table ...
随机推荐
- WWDC-UIKit 中协议与值类型编程实战
本文为 WWDC 2016 Session 419 的部分内容笔记.强烈推荐观看. 设计师来需求了 在我们的 App 中,通常需要自定义一些视图.例如下图: 我们可能会在很多地方用到右边为内容,左边有 ...
- Java基础知识强化之集合框架笔记24:ArrayList存储自定义对象并遍历
1. ArrayList存储自定义对象并遍历 2. 代码示例: Student.java,如下: package cn.itcast_01; public class Student { privat ...
- at91sam9x5 linux 4.1.0下使能蜂鸣器驱动
测试环境: CPU: AT91SAM9X35 Linux: Atmel提供的linux-at91-linux4sam_5.3 (Linux-4.1.0) 转载请注明: 凌云物网智科嵌入式实 ...
- Eclipse下使用Fat Jar插件对源代码进行打包
这两天需要对一个项目进行打包,并在服务器上部署成后台服务模式进行执行,原来使用eclipse进行打包很难用,配置文件容易出错,生成的jar不能正常运行.后来发现Fat Jar Eclipse Plug ...
- 使用Spring简化JDBC操作数据库
Spring的开发初衷是为了减轻企业级开发的复杂度,其对数据库访问的支持亦如此,使用Spring访问数据库能带来以下好处: 1.1 简化代码 使用原生的JDBC访问数据库,一般总是要执行以下步 ...
- 内网映射到公网工具 --- ngrok
ngrok可以将内网映射到公网上,这样就可以在公网上访问你的网络服务. 该工具通常在进行app开发和微信开发时比较有用,这样就可避免在公网服务器上单独部署项目,通过映射,直接连接本地服务即可进行开发. ...
- Dictionary的遍历和修改
/// <summary> /// 初始化一个Dic /// </summary> public static void mainTe ...
- jstl--c:choose标签
今天使用c:choose标签,一直报错: 严重: Servlet.service() for servlet CheckIncome threw exceptionorg.apache.jasper. ...
- SGU 181.X-Sequence
时间限制:0.5s 空间限制:4M 题意: 令X0=A, Xi=(a*Xi-1^2,b*Xi-1+c)%m; 求Xk,(0<=k<=109),(0<=a,b<=100),(1& ...
- 在2015中使用V12版本的ReportView控件,会导致winform窗体不能正常打开
在2015中使用V12版本的ReportView控件,会导致winform窗体不能正常打开,使用V10版本没问题,但2015中默认使用的就是V12版本,所以需要避免使用V12版本