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 ...
随机推荐
- JMX 与系统管理--转
前言 在 Java 程序的运行过程中,对 JVM 和系统的监测一直是 Java 开发人员在开发过程所需要的.一直以来,Java 开发人员必须通过一些底层的 JVM API,比如 JVMPI 和 JVM ...
- Java基础知识强化之集合框架笔记37:用户登录注册案例
1. 登录注册案例分析图解: 2. 用户登录案例 详细分析 和 分包实现: (1)用户登录案例详细分析(面向对象思想) 按照如下的操作,可以让我们更符合面向对象思想: • 有哪些类呢? ...
- Java设计模式02:常用设计模式之工厂模式(创建型模式)
一.工厂模式主要是为创建对象提供过渡接口,以便将创建对象的具体过程屏蔽隔离起来,达到提高灵活性的目的. 工厂模式在<Java与模式>中分为三类: 1)简单工厂模式(Simple Fact ...
- javascript 高级程序设计(三)-数据类型
ECMAScript 中所有类型的值都有与这两个Boolean值等价的值 数据类型 转换为true的值 转换为false的值 Boolean true false( String ...
- CentOS 6.7编译安装PHP 5.6
1.准备编译环境 yum install gcc gcc-c++ pcre* openssl* gd-devel* libxml2-devel bzip2-devel libcurl-devel 2. ...
- Python之路【第十二篇】:JavaScrpt -暂无内容-待更新
Python之路[第十二篇]:JavaScrpt -暂无内容-待更新
- 原生JS与jQuery文档加载完毕的写法
HTML是有执行顺序的,默认是自上而下执行.所以当我们的js代码在html代码下边的时候,可以正常执行,而当我们的js代码在html代码上边的时候,可以就无法正常执行了,这时,我们需要在文档加载完毕的 ...
- U3D 背景音效和事件触发音效
首先,想要在一个游戏添加背景音乐其实很简单,就是利用一个组件 就能够实现音频的播放,不过要实现通过某一个事件,来进行声音的播放,比如跳跃啊什么的: public AudioClip jumpclips ...
- java 字符串转int
//字符转整形 String aa = "23"; //int bb = Integer.parseInt(aa);//两种方式都是可以的 int bb = new Integer ...
- Java方法-数组
[Java数组] 1. 用sort()方法对Java数组进行排序,及如何使用 binarySearch() 方法来查找数组中的元素 binarySearch() 返回值: 如果它包含在数组中,则返回搜 ...