题目链接

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. 《Android群英传》读书笔记 (5) 第十一章 搭建云端服务器 + 第十二章 Android 5.X新特性详解 + 第十三章 Android实例提高

    第十一章 搭建云端服务器 该章主要介绍了移动后端服务的概念以及Bmob的使用,比较简单,所以略过不总结. 第十三章 Android实例提高 该章主要介绍了拼图游戏和2048的小项目实例,主要是代码,所 ...

  2. List(列表)

    List(列表): List的特征是其元素以线性方式存储,集合中可以存放重复对象. List接口主要实现类包括: ArrayList() : 代表长度可以改变得数组.可以对元素进行随机的访问,向Arr ...

  3. 在线预览文件(pdf)

    1.flash版(借助flexpaper工具) 可以把pdf文件用pdf2swf工具转换成swf文件.下载地址http://www.swftools.org/download.html 转换代码如下: ...

  4. Topas命令详解

    Topas命令详解 执行topas命令后如图所示: #topas 操作系统的最全面动态,而又查看方便的性能视图就是topas命令了,下面以topas输出为例,对AIX系统的性能监控做简要描述,供运维工 ...

  5. oracle行列转换总结-转载自ITPUB

    原贴地址:http://www.itpub.net/thread-1017026-1-1.html 谢谢原贴大人 最近论坛很多人提的问题都与行列转换有关系,所以我对行列转换的相关知识做了一个总结, 希 ...

  6. angular.js 数字

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...

  7. 执行hadoop fs -ls时出现错误RuntimeException: core-site.xml not found

    由于暴力关机,Hadoop fs -ls 出现了下图问题: 问题出现的原因是下面红框框里面的东西,我当时以为从另一个节点下载一个conf.cloudera.yarn文件就能解决问题,发现不行啊,于是删 ...

  8. AbstractFactory 模式

    ///////////////////////Product.h////////////// #ifndef _PRODUCT_H_ #define _PRODUCT_H_ class Abstrac ...

  9. 命令行,备份、导入数据库Oracle

    备份库:exp username/password@Database file="h:\datas.dmp" owner=username 导入语句 :imp username2/ ...

  10. web版扫雷小游戏(一)

    作为一名程序猿,平时的爱好也不多,说起游戏,我不太喜欢大型的网游,因为太耗时间,偶尔玩玩经典的单机小游戏,比如windows下自带的游戏扫雷(秀一下,高级下最高纪录110s). 现阶段正在致力于web ...