题目链接

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(模拟)的更多相关文章

  1. POJ3087:Shuffle'm Up(模拟)

    http://poj.org/problem?id=3087 Description A common pastime for poker players at a poker table is to ...

  2. poj3087 Shuffle'm Up(模拟)

    Shuffle'm Up Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10766   Accepted: 4976 Des ...

  3. POJ-3087 Shuffle'm Up (模拟)

    Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuff ...

  4. POJ3087 Shuffle'm Up 简单模拟

    题意:就是给你两副扑克,然后一张盖一张洗牌,不断重复这个过程,看能不能达到目标的扑克顺序 分析:然后就模拟下,-1的情况就是有循环节 #include<cstdio> #include&l ...

  5. 【POJ - 3087】Shuffle'm Up(模拟)

    Shuffle'm Up 直接写中文了 Descriptions: 给定两个长度为len的字符串s1和s2, 接着给出一个长度为len*2的字符串s12. 将字符串s1和s2通过一定的变换变成s12, ...

  6. poj 3087 Shuffle'm Up (模拟过程)

    Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuff ...

  7. POJ3087 Shuffle'm Up —— 打表找规律 / map判重

    题目链接:http://poj.org/problem?id=3087 Shuffle'm Up Time Limit: 1000MS   Memory Limit: 65536K Total Sub ...

  8. poj3087 Shuffle'm Up

    Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuff ...

  9. POJ 3078 - Shuffle'm Up - [模拟题]

    题目链接:http://poj.org/problem?id=3087 Description A common pastime for poker players at a poker table ...

随机推荐

  1. HTML表单介绍

    表单语法结构如下: <form action="url" method="get|post" name="value" enctype ...

  2. 11.2 morning

    noip模拟题day1——棋盘上的问题 day1模拟题 By FancyCoder总览(Overview)注意事项:共3道题目,时间2.5小时.Pascal选手允许使用math库和ansistring ...

  3. 树形dp练习

    /*poj 1463 最小点覆盖 匈牙利*/ #include<iostream> #include<cstdio> #include<cstring> #defi ...

  4. Spire.Barcode好用的条码生在组件

    由于项目的需要,今天在网上找了一下条码的组件,发现了一个简单易用的组件,使用简单,几句代码就搞定了.

  5. JAVA package与import机制

    JAVA package与import机制 http://files.cnblogs.com/files/misybing/JAVA-package-and-import.pdf import org ...

  6. C#开发基于Http的LaTeX数学公式转换器

    本文将讲解如何通过codecogs.com和Google.com提供的API接口来将LaTeX数学函数表达式转化为图片形式.具体思路如下: (1)通过TextBox获取用户输入的LaTeX数学表达式, ...

  7. JSP自定义标签库

    总所周知,JSP自定义标签库,主要是为了去掉JSP页面中的JAVA语句 此处以格式化输出时间戳为指定日期格式为例,简单介绍下JSP自定义标签的过程. 编写标签处理类(可继承自javax.servlet ...

  8. php_curl扩展在WINDOWS2003上如何添加

    一.使用星外PHP安装后 二.修改环境变量,PATH: c:\php;c:\php\ext;%SystemRoot%\system32;

  9. Session技术详解

    1.session简介 在WEB开发中,服务器可以为每个用户浏览器创建一个会话对象(session对象),注意:一个浏览器独占一个session对象(默认情况下).因此,在需要保存用户数据时,服务器程 ...

  10. SGU 163.Wise King

    一道题目长的水题.... 总结就一句话,给出n个(-3~3)的数,一个数m,取任意个数是使这些数的m次幂之和最大. code #include <iostream> #include &l ...