zoukankan      html  css  js  c++  java
  • Shuffle'm Up POJ 3087

    http://acm.hust.edu.cn/vjudge/contest/121377#problem/G 

    根据题意模拟即可

    #include<stdio.h>
    #include<string.h>
    #include<math.h>
    #include<queue>
    using namespace std;
    
    #define maxn 300
    
    char a[maxn*maxn], b[maxn*maxn], s1[maxn], s2[maxn], s[maxn*maxn];
    
    int solve(int n, int step)
    {
        int j=0;
    
        for(int i=0; i<n; i++)
        {
            a[j++] = s2[i];
            a[j++] = s1[i];
        }
    
        a[j]='';
    
        if(!strcmp(a, s)) return step;
    
        if(step == 1) strcpy(b, a);
    
        if(step!=1 && !strcmp(b, a)) return -1;
    
        strncpy(s1, a, n);
        strncpy(s2, a+n, n);
    
        return solve(n, step+1);
    }
    
    int main()
    {
        int T, t=1, n;
        scanf("%d", &T);
    
        while(T --)
        {
            scanf("%d %s %s %s", &n, s1, s2, s);
    
            int ans = solve(n, 1);
    
            printf("%d %d
    ",t++, ans);
        }
        return 0;
    }
    View Code
  • 相关阅读:
    基本数据结构:链表(list)
    字符串函数
    TCHAR
    开源库链接
    视频 链接
    tabbar
    加密
    安全类链接,https
    资本
    审核 -链接 - 发布证书
  • 原文地址:https://www.cnblogs.com/daydayupacm/p/5690667.html
Copyright © 2011-2022 走看看