Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

0ms AC

Posted by tianwei13623613927 at 2018-08-22 18:13:55 on Problem 3087
#include<iostream>
#include<stdio.h>
#include<vector>
#include<map>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<cmath>
using namespace std;

int main()
    {
        ios::sync_with_stdio(false);

        int n,c;
        cin >> n;
        string s1,s2,os1,os2;
        string des;
        int k = 0;
        while(n--){
            cin >> c;
            cin >> os1 >> os2;
            cin >> des;
            s1 = os1;s2 = os2;
            int cnt = 0;
            bool flag = false;
            while(true){
                string tmp = "";
                for(int i = 0; i < c; ++i){
                    tmp += s2[i];
                    tmp += s1[i];
                }
                ++cnt;
                if(tmp == des){
                    flag = true;
                    break;
                }
//                cout << tmp <<endl;
                s1 = tmp.substr(0,c);
                s2 = tmp.substr(c,c);
//                cout << s1 << " "<<  s2 <<endl;
                if(s1 == os1 && s2 == os2){
                    break;
                }
            }
            if(flag){
                cout << ++k << " "<< cnt << endl;
            }
            else{
                cout << ++k <<" " <<-1 << endl;
            }

        }



        return 0;
    }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator